You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,43 @@ This module is used for writing unit tests for your applications, you can access
7
7
It aims to be fully compatibe with the [node.js assert module](http://nodejs.org/api/assert.html), same API and same behavior, just adding support for web browsers.
8
8
The API and code may contain traces of the [CommonJS Unit Testing 1.0 spec](http://wiki.commonjs.org/wiki/Unit_Testing/1.0) which they were based on, but both have evolved significantly since then.
9
9
10
+
A `strict` and a `legacy` mode exist, while it is recommended to only use `strict mode`.
11
+
12
+
## Strict mode
13
+
14
+
When using the `strict mode`, any `assert` function will use the equality used in the strict function mode. So `assert.deepEqual()` will, for example, work the same as `assert.deepStrictEqual()`.
15
+
16
+
It can be accessed using:
17
+
18
+
```js
19
+
constassert=require('assert').strict;
20
+
```
21
+
22
+
## Legacy mode
23
+
24
+
> Deprecated: Use strict mode instead.
25
+
26
+
When accessing `assert` directly instead of using the `strict` property, the
27
+
[Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison) will be used for any function without a
28
+
"strict" in its name (e.g. `assert.deepEqual()`).
29
+
30
+
It can be accessed using:
31
+
32
+
```js
33
+
constassert=require('assert');
34
+
```
35
+
36
+
It is recommended to use the `strict mode` instead as the Abstract Equality Comparison can often have surprising results. Especially
37
+
in case of `assert.deepEqual()` as the used comparison rules there are very lax.
38
+
39
+
E.g.
40
+
41
+
```js
42
+
// WARNING: This does not throw an AssertionError!
0 commit comments