chai 4.3.10 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +7 -1
- package/README.md +13 -71
- package/chai.js +3616 -11088
- package/eslint.config.js +12 -0
- package/index.js +1 -1
- package/lib/chai/assertion.js +152 -163
- package/lib/chai/config.js +35 -15
- package/lib/chai/core/assertions.js +3737 -3656
- package/lib/chai/interface/assert.js +2984 -3046
- package/lib/chai/interface/expect.js +45 -37
- package/lib/chai/interface/should.js +203 -201
- package/lib/chai/utils/addChainableMethod.js +14 -19
- package/lib/chai/utils/addLengthGuard.js +6 -6
- package/lib/chai/utils/addMethod.js +13 -14
- package/lib/chai/utils/addProperty.js +12 -13
- package/lib/chai/utils/compareByInspect.js +7 -12
- package/lib/chai/utils/expectTypes.js +9 -10
- package/lib/chai/utils/flag.js +7 -7
- package/lib/chai/utils/getActual.js +5 -5
- package/lib/chai/utils/getEnumerableProperties.js +2 -3
- package/lib/chai/utils/getMessage.js +9 -13
- package/lib/chai/utils/getOperator.js +13 -10
- package/lib/chai/utils/getOwnEnumerableProperties.js +5 -10
- package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +4 -5
- package/lib/chai/utils/getProperties.js +7 -5
- package/lib/chai/utils/index.js +74 -140
- package/lib/chai/utils/inspect.js +9 -11
- package/lib/chai/utils/isNaN.js +5 -5
- package/lib/chai/utils/isProxyEnabled.js +4 -4
- package/lib/chai/utils/objDisplay.js +6 -11
- package/lib/chai/utils/overwriteChainableMethod.js +13 -14
- package/lib/chai/utils/overwriteMethod.js +18 -19
- package/lib/chai/utils/overwriteProperty.js +17 -19
- package/lib/chai/utils/proxify.js +15 -15
- package/lib/chai/utils/test.js +6 -10
- package/lib/chai/utils/transferFlags.js +6 -8
- package/lib/chai/utils/type-detect.js +20 -0
- package/lib/chai.js +35 -62
- package/package.json +25 -27
- package/register-assert.cjs +3 -0
- package/register-assert.js +3 -1
- package/register-expect.cjs +3 -0
- package/register-expect.js +3 -1
- package/register-should.cjs +3 -0
- package/register-should.js +3 -1
- package/web-test-runner.config.js +20 -0
- package/bower.json +0 -26
- package/index.mjs +0 -14
- package/karma.conf.js +0 -34
- package/karma.sauce.js +0 -41
- package/sauce.browsers.js +0 -106
package/lib/chai/utils/isNaN.js
CHANGED
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
*
|
|
12
12
|
* utils.isNaN(NaN); // true
|
|
13
13
|
*
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {unknown} value The value which has to be checked if it is NaN
|
|
15
|
+
* @returns {boolean}
|
|
15
16
|
* @name isNaN
|
|
16
|
-
* @
|
|
17
|
+
* @private
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
function isNaN(value) {
|
|
19
|
+
function _isNaN(value) {
|
|
20
20
|
// Refer http://www.ecma-international.org/ecma-262/6.0/#sec-isnan-number
|
|
21
21
|
// section's NOTE.
|
|
22
22
|
return value !== value;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// If ECMAScript 6's Number.isNaN is present, prefer that.
|
|
26
|
-
|
|
26
|
+
export const isNaN = Number.isNaN || _isNaN;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import {config} from '../config.js';
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* Chai - isProxyEnabled helper
|
|
@@ -15,10 +15,10 @@ var config = require('../config');
|
|
|
15
15
|
*
|
|
16
16
|
* @namespace Utils
|
|
17
17
|
* @name isProxyEnabled
|
|
18
|
+
* @returns {boolean}
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
module.exports = function isProxyEnabled() {
|
|
20
|
+
export function isProxyEnabled() {
|
|
21
21
|
return config.useProxy &&
|
|
22
22
|
typeof Proxy !== 'undefined' &&
|
|
23
23
|
typeof Reflect !== 'undefined';
|
|
24
|
-
}
|
|
24
|
+
}
|
|
@@ -4,12 +4,8 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var inspect = require('./inspect');
|
|
12
|
-
var config = require('../config');
|
|
7
|
+
import {inspect} from './inspect.js';
|
|
8
|
+
import {config} from '../config.js';
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
* ### .objDisplay(object)
|
|
@@ -18,14 +14,13 @@ var config = require('../config');
|
|
|
18
14
|
* criteria to be inspected in-line for error
|
|
19
15
|
* messages or should be truncated.
|
|
20
16
|
*
|
|
21
|
-
* @param {
|
|
17
|
+
* @param {unknown} obj javascript object to inspect
|
|
22
18
|
* @returns {string} stringified object
|
|
23
19
|
* @name objDisplay
|
|
24
20
|
* @namespace Utils
|
|
25
|
-
* @
|
|
21
|
+
* @public
|
|
26
22
|
*/
|
|
27
|
-
|
|
28
|
-
module.exports = function objDisplay(obj) {
|
|
23
|
+
export function objDisplay(obj) {
|
|
29
24
|
var str = inspect(obj)
|
|
30
25
|
, type = Object.prototype.toString.call(obj);
|
|
31
26
|
|
|
@@ -48,4 +43,4 @@ module.exports = function objDisplay(obj) {
|
|
|
48
43
|
} else {
|
|
49
44
|
return str;
|
|
50
45
|
}
|
|
51
|
-
}
|
|
46
|
+
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import {Assertion} from '../assertion.js';
|
|
8
|
+
import {transferFlags} from './transferFlags.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* ### .overwriteChainableMethod(ctx, name, method, chainingBehavior)
|
|
@@ -16,10 +16,10 @@ var transferFlags = require('./transferFlags');
|
|
|
16
16
|
* name.
|
|
17
17
|
*
|
|
18
18
|
* utils.overwriteChainableMethod(chai.Assertion.prototype, 'lengthOf',
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* function (_super) {
|
|
20
|
+
* }
|
|
21
|
+
* , function (_super) {
|
|
22
|
+
* }
|
|
23
23
|
* );
|
|
24
24
|
*
|
|
25
25
|
* Can also be accessed directly from `chai.Assertion`.
|
|
@@ -31,16 +31,15 @@ var transferFlags = require('./transferFlags');
|
|
|
31
31
|
* expect(myFoo).to.have.lengthOf(3);
|
|
32
32
|
* expect(myFoo).to.have.lengthOf.above(3);
|
|
33
33
|
*
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
34
|
+
* @param {object} ctx object whose method / property is to be overwritten
|
|
35
|
+
* @param {string} name of method / property to overwrite
|
|
36
36
|
* @param {Function} method function that returns a function to be used for name
|
|
37
37
|
* @param {Function} chainingBehavior function that returns a function to be used for property
|
|
38
38
|
* @namespace Utils
|
|
39
39
|
* @name overwriteChainableMethod
|
|
40
|
-
* @
|
|
40
|
+
* @public
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
|
-
module.exports = function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
42
|
+
export function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
44
43
|
var chainableBehavior = ctx.__methods[name];
|
|
45
44
|
|
|
46
45
|
var _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
@@ -50,7 +49,7 @@ module.exports = function overwriteChainableMethod(ctx, name, method, chainingBe
|
|
|
50
49
|
return result;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
var newAssertion = new
|
|
52
|
+
var newAssertion = new Assertion();
|
|
54
53
|
transferFlags(this, newAssertion);
|
|
55
54
|
return newAssertion;
|
|
56
55
|
};
|
|
@@ -62,8 +61,8 @@ module.exports = function overwriteChainableMethod(ctx, name, method, chainingBe
|
|
|
62
61
|
return result;
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
var newAssertion = new
|
|
64
|
+
var newAssertion = new Assertion();
|
|
66
65
|
transferFlags(this, newAssertion);
|
|
67
66
|
return newAssertion;
|
|
68
67
|
};
|
|
69
|
-
}
|
|
68
|
+
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import {Assertion} from '../assertion.js';
|
|
8
|
+
import {addLengthGuard} from './addLengthGuard.js';
|
|
9
|
+
import {flag} from './flag.js';
|
|
10
|
+
import {proxify} from './proxify.js';
|
|
11
|
+
import {transferFlags} from './transferFlags.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* ### .overwriteMethod(ctx, name, fn)
|
|
@@ -18,14 +18,14 @@ var transferFlags = require('./transferFlags');
|
|
|
18
18
|
* to be used for name.
|
|
19
19
|
*
|
|
20
20
|
* utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
21
|
+
* return function (str) {
|
|
22
|
+
* var obj = utils.flag(this, 'object');
|
|
23
|
+
* if (obj instanceof Foo) {
|
|
24
|
+
* new chai.Assertion(obj.value).to.equal(str);
|
|
25
|
+
* } else {
|
|
26
|
+
* _super.apply(this, arguments);
|
|
27
|
+
* }
|
|
27
28
|
* }
|
|
28
|
-
* }
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
31
|
* Can also be accessed directly from `chai.Assertion`.
|
|
@@ -36,15 +36,14 @@ var transferFlags = require('./transferFlags');
|
|
|
36
36
|
*
|
|
37
37
|
* expect(myFoo).to.equal('bar');
|
|
38
38
|
*
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
39
|
+
* @param {object} ctx object whose method is to be overwritten
|
|
40
|
+
* @param {string} name of method to overwrite
|
|
41
41
|
* @param {Function} method function that returns a function to be used for name
|
|
42
42
|
* @namespace Utils
|
|
43
43
|
* @name overwriteMethod
|
|
44
|
-
* @
|
|
44
|
+
* @public
|
|
45
45
|
*/
|
|
46
|
-
|
|
47
|
-
module.exports = function overwriteMethod(ctx, name, method) {
|
|
46
|
+
export function overwriteMethod(ctx, name, method) {
|
|
48
47
|
var _method = ctx[name]
|
|
49
48
|
, _super = function () {
|
|
50
49
|
throw new Error(name + ' is not a function');
|
|
@@ -82,11 +81,11 @@ module.exports = function overwriteMethod(ctx, name, method) {
|
|
|
82
81
|
return result;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
var newAssertion = new
|
|
84
|
+
var newAssertion = new Assertion();
|
|
86
85
|
transferFlags(this, newAssertion);
|
|
87
86
|
return newAssertion;
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
addLengthGuard(overwritingMethodWrapper, name, false);
|
|
91
90
|
ctx[name] = proxify(overwritingMethodWrapper, name);
|
|
92
|
-
}
|
|
91
|
+
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {Assertion} from '../assertion.js';
|
|
8
|
+
import {flag} from './flag.js';
|
|
9
|
+
import {isProxyEnabled} from './isProxyEnabled.js';
|
|
10
|
+
import {transferFlags} from './transferFlags.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* ### .overwriteProperty(ctx, name, fn)
|
|
@@ -16,17 +16,16 @@ var transferFlags = require('./transferFlags');
|
|
|
16
16
|
* access to previous value. Must return function to use as getter.
|
|
17
17
|
*
|
|
18
18
|
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
19
|
+
* return function () {
|
|
20
|
+
* var obj = utils.flag(this, 'object');
|
|
21
|
+
* if (obj instanceof Foo) {
|
|
22
|
+
* new chai.Assertion(obj.name).to.equal('bar');
|
|
23
|
+
* } else {
|
|
24
|
+
* _super.call(this);
|
|
25
|
+
* }
|
|
25
26
|
* }
|
|
26
|
-
* }
|
|
27
27
|
* });
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
29
|
* Can also be accessed directly from `chai.Assertion`.
|
|
31
30
|
*
|
|
32
31
|
* chai.Assertion.overwriteProperty('foo', fn);
|
|
@@ -35,15 +34,14 @@ var transferFlags = require('./transferFlags');
|
|
|
35
34
|
*
|
|
36
35
|
* expect(myFoo).to.be.ok;
|
|
37
36
|
*
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {
|
|
37
|
+
* @param {object} ctx object whose property is to be overwritten
|
|
38
|
+
* @param {string} name of property to overwrite
|
|
40
39
|
* @param {Function} getter function that returns a getter function to be used for name
|
|
41
40
|
* @namespace Utils
|
|
42
41
|
* @name overwriteProperty
|
|
43
|
-
* @
|
|
42
|
+
* @public
|
|
44
43
|
*/
|
|
45
|
-
|
|
46
|
-
module.exports = function overwriteProperty(ctx, name, getter) {
|
|
44
|
+
export function overwriteProperty(ctx, name, getter) {
|
|
47
45
|
var _get = Object.getOwnPropertyDescriptor(ctx, name)
|
|
48
46
|
, _super = function () {};
|
|
49
47
|
|
|
@@ -83,10 +81,10 @@ module.exports = function overwriteProperty(ctx, name, getter) {
|
|
|
83
81
|
return result;
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
var newAssertion = new
|
|
84
|
+
var newAssertion = new Assertion();
|
|
87
85
|
transferFlags(this, newAssertion);
|
|
88
86
|
return newAssertion;
|
|
89
87
|
}
|
|
90
88
|
, configurable: true
|
|
91
89
|
});
|
|
92
|
-
}
|
|
90
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {config} from '../config.js';
|
|
2
|
+
import {flag} from './flag.js';
|
|
3
|
+
import {getProperties} from './getProperties.js';
|
|
4
|
+
import {isProxyEnabled} from './isProxyEnabled.js';
|
|
5
5
|
|
|
6
6
|
/*!
|
|
7
7
|
* Chai - proxify utility
|
|
@@ -9,6 +9,8 @@ var isProxyEnabled = require('./isProxyEnabled');
|
|
|
9
9
|
* MIT Licensed
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
const builtins = ['__flags', '__methods', '_obj', 'assert'];
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* ### .proxify(object)
|
|
14
16
|
*
|
|
@@ -22,15 +24,13 @@ var isProxyEnabled = require('./isProxyEnabled');
|
|
|
22
24
|
* If proxies are unsupported or disabled via the user's Chai config, then
|
|
23
25
|
* return object without modification.
|
|
24
26
|
*
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
27
|
+
* @param {object} obj
|
|
28
|
+
* @param {string} nonChainableMethodName
|
|
29
|
+
* @returns {unknown}
|
|
27
30
|
* @namespace Utils
|
|
28
31
|
* @name proxify
|
|
29
32
|
*/
|
|
30
|
-
|
|
31
|
-
var builtins = ['__flags', '__methods', '_obj', 'assert'];
|
|
32
|
-
|
|
33
|
-
module.exports = function proxify(obj, nonChainableMethodName) {
|
|
33
|
+
export function proxify(obj ,nonChainableMethodName) {
|
|
34
34
|
if (!isProxyEnabled()) return obj;
|
|
35
35
|
|
|
36
36
|
return new Proxy(obj, {
|
|
@@ -98,18 +98,18 @@ module.exports = function proxify(obj, nonChainableMethodName) {
|
|
|
98
98
|
return Reflect.get(target, property);
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
}
|
|
101
|
+
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* # stringDistanceCapped(strA, strB, cap)
|
|
105
105
|
* Return the Levenshtein distance between two strings, but no more than cap.
|
|
106
|
+
*
|
|
106
107
|
* @param {string} strA
|
|
107
108
|
* @param {string} strB
|
|
108
|
-
* @param {number}
|
|
109
|
-
* @
|
|
110
|
-
* @
|
|
109
|
+
* @param {number} cap
|
|
110
|
+
* @returns {number} min(string distance between strA and strB, cap)
|
|
111
|
+
* @private
|
|
111
112
|
*/
|
|
112
|
-
|
|
113
113
|
function stringDistanceCapped(strA, strB, cap) {
|
|
114
114
|
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
115
115
|
return cap;
|
package/lib/chai/utils/test.js
CHANGED
|
@@ -4,25 +4,21 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var flag = require('./flag');
|
|
7
|
+
import {flag} from './flag.js';
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
10
|
* ### .test(object, expression)
|
|
15
11
|
*
|
|
16
12
|
* Test an object for expression.
|
|
17
13
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
14
|
+
* @param {object} obj (constructed Assertion)
|
|
15
|
+
* @param {unknown} args
|
|
16
|
+
* @returns {unknown}
|
|
20
17
|
* @namespace Utils
|
|
21
18
|
* @name test
|
|
22
19
|
*/
|
|
23
|
-
|
|
24
|
-
module.exports = function test(obj, args) {
|
|
20
|
+
export function test(obj, args) {
|
|
25
21
|
var negate = flag(obj, 'negate')
|
|
26
22
|
, expr = args[0];
|
|
27
23
|
return negate ? !expr : expr;
|
|
28
|
-
}
|
|
24
|
+
}
|
|
@@ -12,22 +12,20 @@
|
|
|
12
12
|
* assertion flags (namely `object`, `ssfi`, `lockSsfi`,
|
|
13
13
|
* and `message`) will not be transferred.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
15
|
* var newAssertion = new Assertion();
|
|
17
16
|
* utils.transferFlags(assertion, newAssertion);
|
|
18
17
|
*
|
|
19
18
|
* var anotherAssertion = new Assertion(myObj);
|
|
20
19
|
* utils.transferFlags(assertion, anotherAssertion, false);
|
|
21
20
|
*
|
|
22
|
-
* @param {Assertion} assertion the assertion to transfer the flags from
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
21
|
+
* @param {import('../assertion.js').Assertion} assertion the assertion to transfer the flags from
|
|
22
|
+
* @param {object} object the object to transfer the flags to; usually a new assertion
|
|
23
|
+
* @param {boolean} includeAll
|
|
25
24
|
* @namespace Utils
|
|
26
25
|
* @name transferFlags
|
|
27
|
-
* @
|
|
26
|
+
* @private
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
|
-
module.exports = function transferFlags(assertion, object, includeAll) {
|
|
28
|
+
export function transferFlags(assertion, object, includeAll) {
|
|
31
29
|
var flags = assertion.__flags || (assertion.__flags = Object.create(null));
|
|
32
30
|
|
|
33
31
|
if (!object.__flags) {
|
|
@@ -42,4 +40,4 @@ module.exports = function transferFlags(assertion, object, includeAll) {
|
|
|
42
40
|
object.__flags[flag] = flags[flag];
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
|
-
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {unknown} obj
|
|
3
|
+
* @returns {string}
|
|
4
|
+
*/
|
|
5
|
+
export function type(obj) {
|
|
6
|
+
if (typeof obj === 'undefined') {
|
|
7
|
+
return 'undefined';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (obj === null) {
|
|
11
|
+
return 'null';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const stringTag = obj[Symbol.toStringTag];
|
|
15
|
+
if (typeof stringTag === 'string') {
|
|
16
|
+
return stringTag;
|
|
17
|
+
}
|
|
18
|
+
const type = Object.prototype.toString.call(obj).slice(8, -1);
|
|
19
|
+
return type;
|
|
20
|
+
}
|
package/lib/chai.js
CHANGED
|
@@ -4,37 +4,40 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import * as util from './chai/utils/index.js';
|
|
8
|
+
import {AssertionError} from 'assertion-error';
|
|
9
|
+
import {config} from './chai/config.js';
|
|
10
|
+
import './chai/core/assertions.js';
|
|
11
|
+
import {expect} from './chai/interface/expect.js';
|
|
12
|
+
import {Assertion} from './chai/assertion.js';
|
|
13
|
+
import * as should from './chai/interface/should.js';
|
|
14
|
+
import {assert} from './chai/interface/assert.js';
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
* Chai version
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
exports.version = '4.3.8';
|
|
14
|
-
|
|
15
|
-
/*!
|
|
16
|
-
* Assertion Error
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
exports.AssertionError = require('assertion-error');
|
|
20
|
-
|
|
21
|
-
/*!
|
|
22
|
-
* Utils for plugins (not exported)
|
|
23
|
-
*/
|
|
16
|
+
const used = [];
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
// Assertion Error
|
|
19
|
+
export {AssertionError};
|
|
26
20
|
|
|
27
21
|
/**
|
|
28
22
|
* # .use(function)
|
|
29
23
|
*
|
|
30
24
|
* Provides a way to extend the internals of Chai.
|
|
31
25
|
*
|
|
32
|
-
* @param {Function}
|
|
26
|
+
* @param {Function} fn
|
|
33
27
|
* @returns {this} for chaining
|
|
34
|
-
* @
|
|
28
|
+
* @public
|
|
35
29
|
*/
|
|
30
|
+
export function use(fn) {
|
|
31
|
+
const exports = {
|
|
32
|
+
AssertionError,
|
|
33
|
+
util,
|
|
34
|
+
config,
|
|
35
|
+
expect,
|
|
36
|
+
assert,
|
|
37
|
+
Assertion,
|
|
38
|
+
...should
|
|
39
|
+
};
|
|
36
40
|
|
|
37
|
-
exports.use = function (fn) {
|
|
38
41
|
if (!~used.indexOf(fn)) {
|
|
39
42
|
fn(exports, util);
|
|
40
43
|
used.push(fn);
|
|
@@ -43,50 +46,20 @@ exports.use = function (fn) {
|
|
|
43
46
|
return exports;
|
|
44
47
|
};
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
exports.util = util;
|
|
51
|
-
|
|
52
|
-
/*!
|
|
53
|
-
* Configuration
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
var config = require('./chai/config');
|
|
57
|
-
exports.config = config;
|
|
58
|
-
|
|
59
|
-
/*!
|
|
60
|
-
* Primary `Assertion` prototype
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
var assertion = require('./chai/assertion');
|
|
64
|
-
exports.use(assertion);
|
|
65
|
-
|
|
66
|
-
/*!
|
|
67
|
-
* Core Assertions
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
var core = require('./chai/core/assertions');
|
|
71
|
-
exports.use(core);
|
|
72
|
-
|
|
73
|
-
/*!
|
|
74
|
-
* Expect interface
|
|
75
|
-
*/
|
|
49
|
+
// Utility Functions
|
|
50
|
+
export {util};
|
|
76
51
|
|
|
77
|
-
|
|
78
|
-
|
|
52
|
+
// Configuration
|
|
53
|
+
export {config};
|
|
79
54
|
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
55
|
+
// Primary `Assertion` prototype
|
|
56
|
+
export * from './chai/assertion.js';
|
|
83
57
|
|
|
84
|
-
|
|
85
|
-
|
|
58
|
+
// Expect interface
|
|
59
|
+
export * from './chai/interface/expect.js';
|
|
86
60
|
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
*/
|
|
61
|
+
// Should interface
|
|
62
|
+
export * from './chai/interface/should.js';
|
|
90
63
|
|
|
91
|
-
|
|
92
|
-
|
|
64
|
+
// Assert interface
|
|
65
|
+
export * from './chai/interface/assert.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Jake Luer <jake@alogicalparadox.com>",
|
|
3
3
|
"name": "chai",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"test",
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
"Veselin Todorov <hi@vesln.com>",
|
|
18
19
|
"John Firebaugh <john.firebaugh@gmail.com>"
|
|
19
20
|
],
|
|
20
|
-
"version": "
|
|
21
|
+
"version": "5.1.2",
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|
|
23
24
|
"url": "https://github.com/chaijs/chai"
|
|
@@ -25,39 +26,36 @@
|
|
|
25
26
|
"bugs": {
|
|
26
27
|
"url": "https://github.com/chaijs/chai/issues"
|
|
27
28
|
},
|
|
28
|
-
"main": "./
|
|
29
|
-
"exports": {
|
|
30
|
-
".": {
|
|
31
|
-
"require": "./index.js",
|
|
32
|
-
"import": "./index.mjs"
|
|
33
|
-
},
|
|
34
|
-
"./*": "./*"
|
|
35
|
-
},
|
|
29
|
+
"main": "./chai.js",
|
|
36
30
|
"scripts": {
|
|
37
|
-
"
|
|
31
|
+
"prebuild": "npm run clean",
|
|
32
|
+
"build": "npm run build:esm",
|
|
33
|
+
"build:esm": "esbuild --bundle --format=esm --keep-names --outfile=chai.js index.js",
|
|
34
|
+
"pretest": "npm run lint && npm run build",
|
|
35
|
+
"test": "npm run test-node && npm run test-chrome",
|
|
36
|
+
"test-node": "mocha --require ./test/bootstrap/index.js --reporter dot test/*.js",
|
|
37
|
+
"test-chrome": "web-test-runner --playwright",
|
|
38
|
+
"lint": "eslint lib/",
|
|
39
|
+
"clean": "rm -f chai.js coverage"
|
|
38
40
|
},
|
|
39
41
|
"engines": {
|
|
40
|
-
"node": ">=
|
|
42
|
+
"node": ">=12"
|
|
41
43
|
},
|
|
42
44
|
"dependencies": {
|
|
43
|
-
"assertion-error": "^
|
|
44
|
-
"check-error": "^1.
|
|
45
|
-
"deep-eql": "^
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"pathval": "^1.1.1",
|
|
49
|
-
"type-detect": "^4.0.8"
|
|
45
|
+
"assertion-error": "^2.0.1",
|
|
46
|
+
"check-error": "^2.1.1",
|
|
47
|
+
"deep-eql": "^5.0.1",
|
|
48
|
+
"loupe": "^3.1.0",
|
|
49
|
+
"pathval": "^2.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"karma-mocha": "^2.0.1",
|
|
60
|
-
"karma-sauce-launcher": "^4.1.4",
|
|
52
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
53
|
+
"@web/dev-server-rollup": "^0.6.1",
|
|
54
|
+
"@web/test-runner": "^0.18.0",
|
|
55
|
+
"@web/test-runner-playwright": "^0.11.0",
|
|
56
|
+
"esbuild": "^0.19.10",
|
|
57
|
+
"eslint": "^8.56.0",
|
|
58
|
+
"eslint-plugin-jsdoc": "^48.0.4",
|
|
61
59
|
"mocha": "^10.2.0"
|
|
62
60
|
}
|
|
63
61
|
}
|
package/register-assert.js
CHANGED
package/register-expect.js
CHANGED