Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristján Oddsson committed Dec 28, 2023
1 parent c245af1 commit 082c7e2
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,46 +71,28 @@ You can also use it within the browser; install via npm and use the `chai.js` fi
Import the library in your code, and then pick one of the styles you'd like to use - either `assert`, `expect` or `should`:

```js
var chai = require('chai');
var assert = chai.assert; // Using Assert style
var expect = chai.expect; // Using Expect style
var should = chai.should(); // Using Should style
```

### Pre-Native Modules Usage (_registers the chai testing style globally_)

```js
require('chai/register-assert'); // Using Assert style
require('chai/register-expect'); // Using Expect style
require('chai/register-should'); // Using Should style
```

### Pre-Native Modules Usage (_as local variables_)

```js
const { assert } = require('chai'); // Using Assert style
const { expect } = require('chai'); // Using Expect style
const { should } = require('chai'); // Using Should style
should(); // Modifies `Object.prototype`

const { expect, use } = require('chai'); // Creates local variables `expect` and `use`; useful for plugin use
import { assert } from 'chai'; // Using Assert style
import { expect } from 'chai'; // Using Expect style
import { should } from 'chai'; // Using Should style
```

### Native Modules Usage (_registers the chai testing style globally_)
### Register the chai testing style globally

```js
import 'chai/register-assert'; // Using Assert style
import 'chai/register-expect'; // Using Expect style
import 'chai/register-should'; // Using Should style
```

### Native Modules Usage (_local import only_)
### Import assertion styles as local variables

```js
import { assert } from 'chai'; // Using Assert style
import { expect } from 'chai'; // Using Expect style
import { should } from 'chai'; // Using Should style
should(); // Modifies `Object.prototype`

import { expect, use } from 'chai'; // Creates local variables `expect` and `use`; useful for plugin use
```

### Usage with Mocha
Expand Down

0 comments on commit 082c7e2

Please sign in to comment.