chai 4.2.0 → 4.3.0
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/README.md +2 -2
- package/chai.js +141 -43
- package/index.mjs +13 -0
- package/karma.conf.js +7 -1
- package/karma.sauce.js +1 -1
- package/lib/chai/assertion.js +12 -2
- package/lib/chai/core/assertions.js +37 -12
- package/lib/chai/interface/assert.js +1 -1
- package/lib/chai/interface/should.js +2 -1
- package/lib/chai/utils/getOperator.js +55 -0
- package/lib/chai/utils/index.js +6 -0
- package/lib/chai.js +1 -1
- package/package.json +12 -5
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<a href="https://www.npmjs.com/package/chai">
|
|
27
27
|
<img
|
|
28
28
|
alt="node:?"
|
|
29
|
-
src="https://img.shields.io/badge/node-%3E=
|
|
29
|
+
src="https://img.shields.io/badge/node-%3E=8.0-blue.svg?style=flat-square"
|
|
30
30
|
/>
|
|
31
31
|
</a>
|
|
32
32
|
<br/>
|
|
@@ -94,7 +94,7 @@ Chai is an _assertion library_, similar to Node's built-in `assert`. It makes te
|
|
|
94
94
|
|
|
95
95
|
`chai` is available on [npm](http://npmjs.org). To install it, type:
|
|
96
96
|
|
|
97
|
-
$ npm install chai
|
|
97
|
+
$ npm install --save-dev chai
|
|
98
98
|
|
|
99
99
|
### Browsers
|
|
100
100
|
|
package/chai.js
CHANGED
|
@@ -14,7 +14,7 @@ var used = [];
|
|
|
14
14
|
* Chai version
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
exports.version = '4.
|
|
17
|
+
exports.version = '4.3.0';
|
|
18
18
|
|
|
19
19
|
/*!
|
|
20
20
|
* Assertion Error
|
|
@@ -95,7 +95,7 @@ exports.use(should);
|
|
|
95
95
|
var assert = require('./chai/interface/assert');
|
|
96
96
|
exports.use(assert);
|
|
97
97
|
|
|
98
|
-
},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":
|
|
98
|
+
},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":23,"assertion-error":34}],3:[function(require,module,exports){
|
|
99
99
|
/*!
|
|
100
100
|
* chai
|
|
101
101
|
* http://chaijs.com
|
|
@@ -236,11 +236,21 @@ module.exports = function (_chai, util) {
|
|
|
236
236
|
if (!ok) {
|
|
237
237
|
msg = util.getMessage(this, arguments);
|
|
238
238
|
var actual = util.getActual(this, arguments);
|
|
239
|
-
|
|
239
|
+
var assertionErrorObjectProperties = {
|
|
240
240
|
actual: actual
|
|
241
241
|
, expected: expected
|
|
242
242
|
, showDiff: showDiff
|
|
243
|
-
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
var operator = util.getOperator(this, arguments);
|
|
246
|
+
if (operator) {
|
|
247
|
+
assertionErrorObjectProperties.operator = operator;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
throw new AssertionError(
|
|
251
|
+
msg,
|
|
252
|
+
assertionErrorObjectProperties,
|
|
253
|
+
(config.includeStack) ? this.assert : flag(this, 'ssfi'));
|
|
244
254
|
}
|
|
245
255
|
};
|
|
246
256
|
|
|
@@ -894,8 +904,13 @@ module.exports = function (chai, _) {
|
|
|
894
904
|
// objects with a custom `@@toStringTag`.
|
|
895
905
|
if (val !== Object(val)) {
|
|
896
906
|
throw new AssertionError(
|
|
897
|
-
flagMsg + '
|
|
898
|
-
|
|
907
|
+
flagMsg + 'the given combination of arguments ('
|
|
908
|
+
+ objType + ' and '
|
|
909
|
+
+ _.type(val).toLowerCase() + ')'
|
|
910
|
+
+ ' is invalid for this assertion. '
|
|
911
|
+
+ 'You can use an array, a map, an object, a set, a string, '
|
|
912
|
+
+ 'or a weakset instead of a '
|
|
913
|
+
+ _.type(val).toLowerCase(),
|
|
899
914
|
undefined,
|
|
900
915
|
ssfi
|
|
901
916
|
);
|
|
@@ -1300,7 +1315,7 @@ module.exports = function (chai, _) {
|
|
|
1300
1315
|
*
|
|
1301
1316
|
* Add `.not` earlier in the chain to negate `.arguments`. However, it's often
|
|
1302
1317
|
* best to assert which type the target is expected to be, rather than
|
|
1303
|
-
* asserting that
|
|
1318
|
+
* asserting that it’s not an `arguments` object.
|
|
1304
1319
|
*
|
|
1305
1320
|
* expect('foo').to.be.a('string'); // Recommended
|
|
1306
1321
|
* expect('foo').to.not.be.arguments; // Not recommended
|
|
@@ -2282,7 +2297,7 @@ module.exports = function (chai, _) {
|
|
|
2282
2297
|
* a `descriptor`. The problem is that it creates uncertain expectations by
|
|
2283
2298
|
* asserting that the target either doesn't have a property descriptor with
|
|
2284
2299
|
* the given key `name`, or that it does have a property descriptor with the
|
|
2285
|
-
* given key `name` but
|
|
2300
|
+
* given key `name` but it’s not deeply equal to the given `descriptor`. It's
|
|
2286
2301
|
* often best to identify the exact output that's expected, and then write an
|
|
2287
2302
|
* assertion that only accepts that exact output.
|
|
2288
2303
|
*
|
|
@@ -3311,8 +3326,9 @@ module.exports = function (chai, _) {
|
|
|
3311
3326
|
new Assertion(obj, flagMsg, ssfi, true).is.a('number');
|
|
3312
3327
|
if (typeof expected !== 'number' || typeof delta !== 'number') {
|
|
3313
3328
|
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
3329
|
+
var deltaMessage = delta === undefined ? ", and a delta is required" : "";
|
|
3314
3330
|
throw new AssertionError(
|
|
3315
|
-
flagMsg + 'the arguments to closeTo or approximately must be numbers',
|
|
3331
|
+
flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
|
|
3316
3332
|
undefined,
|
|
3317
3333
|
ssfi
|
|
3318
3334
|
);
|
|
@@ -3478,6 +3494,14 @@ module.exports = function (chai, _) {
|
|
|
3478
3494
|
* expect(1).to.equal(1); // Recommended
|
|
3479
3495
|
* expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended
|
|
3480
3496
|
*
|
|
3497
|
+
* It can also be chained with `.contain` or `.include`, which will work with
|
|
3498
|
+
* both arrays and strings:
|
|
3499
|
+
*
|
|
3500
|
+
* expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
|
|
3501
|
+
* expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
|
|
3502
|
+
* expect([1,2,3]).to.contain.oneOf([3,4,5])
|
|
3503
|
+
* expect([1,2,3]).to.not.contain.oneOf([4,5,6])
|
|
3504
|
+
*
|
|
3481
3505
|
* `.oneOf` accepts an optional `msg` argument which is a custom error message
|
|
3482
3506
|
* to show when the assertion fails. The message can also be given as the
|
|
3483
3507
|
* second argument to `expect`.
|
|
@@ -3496,16 +3520,27 @@ module.exports = function (chai, _) {
|
|
|
3496
3520
|
if (msg) flag(this, 'message', msg);
|
|
3497
3521
|
var expected = flag(this, 'object')
|
|
3498
3522
|
, flagMsg = flag(this, 'message')
|
|
3499
|
-
, ssfi = flag(this, 'ssfi')
|
|
3523
|
+
, ssfi = flag(this, 'ssfi')
|
|
3524
|
+
, contains = flag(this, 'contains');
|
|
3500
3525
|
new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
|
|
3501
3526
|
|
|
3502
|
-
|
|
3527
|
+
if (contains) {
|
|
3528
|
+
this.assert(
|
|
3529
|
+
list.some(function(possibility) { return expected.indexOf(possibility) > -1 })
|
|
3530
|
+
, 'expected #{this} to contain one of #{exp}'
|
|
3531
|
+
, 'expected #{this} to not contain one of #{exp}'
|
|
3532
|
+
, list
|
|
3533
|
+
, expected
|
|
3534
|
+
);
|
|
3535
|
+
} else {
|
|
3536
|
+
this.assert(
|
|
3503
3537
|
list.indexOf(expected) > -1
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3538
|
+
, 'expected #{this} to be one of #{exp}'
|
|
3539
|
+
, 'expected #{this} to not be one of #{exp}'
|
|
3540
|
+
, list
|
|
3541
|
+
, expected
|
|
3542
|
+
);
|
|
3543
|
+
}
|
|
3509
3544
|
}
|
|
3510
3545
|
|
|
3511
3546
|
Assertion.addMethod('oneOf', oneOf);
|
|
@@ -5993,7 +6028,7 @@ module.exports = function (chai, util) {
|
|
|
5993
6028
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]);
|
|
5994
6029
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
|
|
5995
6030
|
*
|
|
5996
|
-
* @name
|
|
6031
|
+
* @name hasAnyDeepKeys
|
|
5997
6032
|
* @param {Mixed} object
|
|
5998
6033
|
* @param {Array|Object} keys
|
|
5999
6034
|
* @param {String} message
|
|
@@ -7344,7 +7379,8 @@ module.exports = function (chai, util) {
|
|
|
7344
7379
|
if (this instanceof String
|
|
7345
7380
|
|| this instanceof Number
|
|
7346
7381
|
|| this instanceof Boolean
|
|
7347
|
-
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
7382
|
+
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
7383
|
+
|| typeof BigInt === 'function' && this instanceof BigInt) {
|
|
7348
7384
|
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
7349
7385
|
}
|
|
7350
7386
|
return new Assertion(this, null, shouldGetter);
|
|
@@ -7702,7 +7738,7 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
|
|
|
7702
7738
|
});
|
|
7703
7739
|
};
|
|
7704
7740
|
|
|
7705
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
7741
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],10:[function(require,module,exports){
|
|
7706
7742
|
var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
|
7707
7743
|
|
|
7708
7744
|
/*!
|
|
@@ -7834,7 +7870,7 @@ module.exports = function addMethod(ctx, name, method) {
|
|
|
7834
7870
|
ctx[name] = proxify(methodWrapper, name);
|
|
7835
7871
|
};
|
|
7836
7872
|
|
|
7837
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
7873
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],12:[function(require,module,exports){
|
|
7838
7874
|
/*!
|
|
7839
7875
|
* Chai - addProperty utility
|
|
7840
7876
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7908,7 +7944,7 @@ module.exports = function addProperty(ctx, name, getter) {
|
|
|
7908
7944
|
});
|
|
7909
7945
|
};
|
|
7910
7946
|
|
|
7911
|
-
},{"../../chai":2,"./flag":15,"./isProxyEnabled":
|
|
7947
|
+
},{"../../chai":2,"./flag":15,"./isProxyEnabled":26,"./transferFlags":33}],13:[function(require,module,exports){
|
|
7912
7948
|
/*!
|
|
7913
7949
|
* Chai - compareByInspect utility
|
|
7914
7950
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7941,7 +7977,7 @@ module.exports = function compareByInspect(a, b) {
|
|
|
7941
7977
|
return inspect(a) < inspect(b) ? -1 : 1;
|
|
7942
7978
|
};
|
|
7943
7979
|
|
|
7944
|
-
},{"./inspect":
|
|
7980
|
+
},{"./inspect":24}],14:[function(require,module,exports){
|
|
7945
7981
|
/*!
|
|
7946
7982
|
* Chai - expectTypes utility
|
|
7947
7983
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7994,7 +8030,7 @@ module.exports = function expectTypes(obj, types) {
|
|
|
7994
8030
|
}
|
|
7995
8031
|
};
|
|
7996
8032
|
|
|
7997
|
-
},{"./flag":15,"assertion-error":
|
|
8033
|
+
},{"./flag":15,"assertion-error":34,"type-detect":39}],15:[function(require,module,exports){
|
|
7998
8034
|
/*!
|
|
7999
8035
|
* Chai - flag utility
|
|
8000
8036
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8131,7 +8167,64 @@ module.exports = function getMessage(obj, args) {
|
|
|
8131
8167
|
return flagMsg ? flagMsg + ': ' + msg : msg;
|
|
8132
8168
|
};
|
|
8133
8169
|
|
|
8134
|
-
},{"./flag":15,"./getActual":16,"./objDisplay":
|
|
8170
|
+
},{"./flag":15,"./getActual":16,"./objDisplay":27}],19:[function(require,module,exports){
|
|
8171
|
+
var type = require('type-detect');
|
|
8172
|
+
|
|
8173
|
+
var flag = require('./flag');
|
|
8174
|
+
|
|
8175
|
+
function isObjectType(obj) {
|
|
8176
|
+
var objectType = type(obj);
|
|
8177
|
+
var objectTypes = ['Array', 'Object', 'function'];
|
|
8178
|
+
|
|
8179
|
+
return objectTypes.indexOf(objectType) !== -1;
|
|
8180
|
+
}
|
|
8181
|
+
|
|
8182
|
+
/**
|
|
8183
|
+
* ### .getOperator(message)
|
|
8184
|
+
*
|
|
8185
|
+
* Extract the operator from error message.
|
|
8186
|
+
* Operator defined is based on below link
|
|
8187
|
+
* https://nodejs.org/api/assert.html#assert_assert.
|
|
8188
|
+
*
|
|
8189
|
+
* Returns the `operator` or `undefined` value for an Assertion.
|
|
8190
|
+
*
|
|
8191
|
+
* @param {Object} object (constructed Assertion)
|
|
8192
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
|
8193
|
+
* @namespace Utils
|
|
8194
|
+
* @name getOperator
|
|
8195
|
+
* @api public
|
|
8196
|
+
*/
|
|
8197
|
+
|
|
8198
|
+
module.exports = function getOperator(obj, args) {
|
|
8199
|
+
var operator = flag(obj, 'operator');
|
|
8200
|
+
var negate = flag(obj, 'negate');
|
|
8201
|
+
var expected = args[3];
|
|
8202
|
+
var msg = negate ? args[2] : args[1];
|
|
8203
|
+
|
|
8204
|
+
if (operator) {
|
|
8205
|
+
return operator;
|
|
8206
|
+
}
|
|
8207
|
+
|
|
8208
|
+
if (typeof msg === 'function') msg = msg();
|
|
8209
|
+
|
|
8210
|
+
msg = msg || '';
|
|
8211
|
+
if (!msg) {
|
|
8212
|
+
return undefined;
|
|
8213
|
+
}
|
|
8214
|
+
|
|
8215
|
+
if (/\shave\s/.test(msg)) {
|
|
8216
|
+
return undefined;
|
|
8217
|
+
}
|
|
8218
|
+
|
|
8219
|
+
var isObject = isObjectType(expected);
|
|
8220
|
+
if (/\snot\s/.test(msg)) {
|
|
8221
|
+
return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
|
|
8222
|
+
}
|
|
8223
|
+
|
|
8224
|
+
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
|
8225
|
+
};
|
|
8226
|
+
|
|
8227
|
+
},{"./flag":15,"type-detect":39}],20:[function(require,module,exports){
|
|
8135
8228
|
/*!
|
|
8136
8229
|
* Chai - getOwnEnumerableProperties utility
|
|
8137
8230
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8162,7 +8255,7 @@ module.exports = function getOwnEnumerableProperties(obj) {
|
|
|
8162
8255
|
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
8163
8256
|
};
|
|
8164
8257
|
|
|
8165
|
-
},{"./getOwnEnumerablePropertySymbols":
|
|
8258
|
+
},{"./getOwnEnumerablePropertySymbols":21}],21:[function(require,module,exports){
|
|
8166
8259
|
/*!
|
|
8167
8260
|
* Chai - getOwnEnumerablePropertySymbols utility
|
|
8168
8261
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8191,7 +8284,7 @@ module.exports = function getOwnEnumerablePropertySymbols(obj) {
|
|
|
8191
8284
|
});
|
|
8192
8285
|
};
|
|
8193
8286
|
|
|
8194
|
-
},{}],
|
|
8287
|
+
},{}],22:[function(require,module,exports){
|
|
8195
8288
|
/*!
|
|
8196
8289
|
* Chai - getProperties utility
|
|
8197
8290
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8229,7 +8322,7 @@ module.exports = function getProperties(object) {
|
|
|
8229
8322
|
return result;
|
|
8230
8323
|
};
|
|
8231
8324
|
|
|
8232
|
-
},{}],
|
|
8325
|
+
},{}],23:[function(require,module,exports){
|
|
8233
8326
|
/*!
|
|
8234
8327
|
* chai
|
|
8235
8328
|
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8403,7 +8496,12 @@ exports.isProxyEnabled = require('./isProxyEnabled');
|
|
|
8403
8496
|
|
|
8404
8497
|
exports.isNaN = require('./isNaN');
|
|
8405
8498
|
|
|
8406
|
-
|
|
8499
|
+
/*!
|
|
8500
|
+
* getOperator method
|
|
8501
|
+
*/
|
|
8502
|
+
|
|
8503
|
+
exports.getOperator = require('./getOperator');
|
|
8504
|
+
},{"./addChainableMethod":9,"./addLengthGuard":10,"./addMethod":11,"./addProperty":12,"./compareByInspect":13,"./expectTypes":14,"./flag":15,"./getActual":16,"./getMessage":18,"./getOperator":19,"./getOwnEnumerableProperties":20,"./getOwnEnumerablePropertySymbols":21,"./inspect":24,"./isNaN":25,"./isProxyEnabled":26,"./objDisplay":27,"./overwriteChainableMethod":28,"./overwriteMethod":29,"./overwriteProperty":30,"./proxify":31,"./test":32,"./transferFlags":33,"check-error":35,"deep-eql":36,"get-func-name":37,"pathval":38,"type-detect":39}],24:[function(require,module,exports){
|
|
8407
8505
|
// This is (almost) directly from Node.js utils
|
|
8408
8506
|
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
|
8409
8507
|
|
|
@@ -8781,7 +8879,7 @@ function objectToString(o) {
|
|
|
8781
8879
|
return Object.prototype.toString.call(o);
|
|
8782
8880
|
}
|
|
8783
8881
|
|
|
8784
|
-
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":
|
|
8882
|
+
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":22,"get-func-name":37}],25:[function(require,module,exports){
|
|
8785
8883
|
/*!
|
|
8786
8884
|
* Chai - isNaN utility
|
|
8787
8885
|
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
|
@@ -8809,7 +8907,7 @@ function isNaN(value) {
|
|
|
8809
8907
|
// If ECMAScript 6's Number.isNaN is present, prefer that.
|
|
8810
8908
|
module.exports = Number.isNaN || isNaN;
|
|
8811
8909
|
|
|
8812
|
-
},{}],
|
|
8910
|
+
},{}],26:[function(require,module,exports){
|
|
8813
8911
|
var config = require('../config');
|
|
8814
8912
|
|
|
8815
8913
|
/*!
|
|
@@ -8835,7 +8933,7 @@ module.exports = function isProxyEnabled() {
|
|
|
8835
8933
|
typeof Reflect !== 'undefined';
|
|
8836
8934
|
};
|
|
8837
8935
|
|
|
8838
|
-
},{"../config":4}],
|
|
8936
|
+
},{"../config":4}],27:[function(require,module,exports){
|
|
8839
8937
|
/*!
|
|
8840
8938
|
* Chai - flag utility
|
|
8841
8939
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8887,7 +8985,7 @@ module.exports = function objDisplay(obj) {
|
|
|
8887
8985
|
}
|
|
8888
8986
|
};
|
|
8889
8987
|
|
|
8890
|
-
},{"../config":4,"./inspect":
|
|
8988
|
+
},{"../config":4,"./inspect":24}],28:[function(require,module,exports){
|
|
8891
8989
|
/*!
|
|
8892
8990
|
* Chai - overwriteChainableMethod utility
|
|
8893
8991
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8958,7 +9056,7 @@ module.exports = function overwriteChainableMethod(ctx, name, method, chainingBe
|
|
|
8958
9056
|
};
|
|
8959
9057
|
};
|
|
8960
9058
|
|
|
8961
|
-
},{"../../chai":2,"./transferFlags":
|
|
9059
|
+
},{"../../chai":2,"./transferFlags":33}],29:[function(require,module,exports){
|
|
8962
9060
|
/*!
|
|
8963
9061
|
* Chai - overwriteMethod utility
|
|
8964
9062
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9052,7 +9150,7 @@ module.exports = function overwriteMethod(ctx, name, method) {
|
|
|
9052
9150
|
ctx[name] = proxify(overwritingMethodWrapper, name);
|
|
9053
9151
|
};
|
|
9054
9152
|
|
|
9055
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
9153
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],30:[function(require,module,exports){
|
|
9056
9154
|
/*!
|
|
9057
9155
|
* Chai - overwriteProperty utility
|
|
9058
9156
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9146,7 +9244,7 @@ module.exports = function overwriteProperty(ctx, name, getter) {
|
|
|
9146
9244
|
});
|
|
9147
9245
|
};
|
|
9148
9246
|
|
|
9149
|
-
},{"../../chai":2,"./flag":15,"./isProxyEnabled":
|
|
9247
|
+
},{"../../chai":2,"./flag":15,"./isProxyEnabled":26,"./transferFlags":33}],31:[function(require,module,exports){
|
|
9150
9248
|
var config = require('../config');
|
|
9151
9249
|
var flag = require('./flag');
|
|
9152
9250
|
var getProperties = require('./getProperties');
|
|
@@ -9295,7 +9393,7 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
9295
9393
|
return memo[strA.length][strB.length];
|
|
9296
9394
|
}
|
|
9297
9395
|
|
|
9298
|
-
},{"../config":4,"./flag":15,"./getProperties":
|
|
9396
|
+
},{"../config":4,"./flag":15,"./getProperties":22,"./isProxyEnabled":26}],32:[function(require,module,exports){
|
|
9299
9397
|
/*!
|
|
9300
9398
|
* Chai - test utility
|
|
9301
9399
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9325,7 +9423,7 @@ module.exports = function test(obj, args) {
|
|
|
9325
9423
|
return negate ? !expr : expr;
|
|
9326
9424
|
};
|
|
9327
9425
|
|
|
9328
|
-
},{"./flag":15}],
|
|
9426
|
+
},{"./flag":15}],33:[function(require,module,exports){
|
|
9329
9427
|
/*!
|
|
9330
9428
|
* Chai - transferFlags utility
|
|
9331
9429
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9372,7 +9470,7 @@ module.exports = function transferFlags(assertion, object, includeAll) {
|
|
|
9372
9470
|
}
|
|
9373
9471
|
};
|
|
9374
9472
|
|
|
9375
|
-
},{}],
|
|
9473
|
+
},{}],34:[function(require,module,exports){
|
|
9376
9474
|
/*!
|
|
9377
9475
|
* assertion-error
|
|
9378
9476
|
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
|
@@ -9490,7 +9588,7 @@ AssertionError.prototype.toJSON = function (stack) {
|
|
|
9490
9588
|
return props;
|
|
9491
9589
|
};
|
|
9492
9590
|
|
|
9493
|
-
},{}],
|
|
9591
|
+
},{}],35:[function(require,module,exports){
|
|
9494
9592
|
'use strict';
|
|
9495
9593
|
|
|
9496
9594
|
/* !
|
|
@@ -9664,7 +9762,7 @@ module.exports = {
|
|
|
9664
9762
|
getConstructorName: getConstructorName,
|
|
9665
9763
|
};
|
|
9666
9764
|
|
|
9667
|
-
},{}],
|
|
9765
|
+
},{}],36:[function(require,module,exports){
|
|
9668
9766
|
'use strict';
|
|
9669
9767
|
/* globals Symbol: false, Uint8Array: false, WeakMap: false */
|
|
9670
9768
|
/*!
|
|
@@ -10121,7 +10219,7 @@ function isPrimitive(value) {
|
|
|
10121
10219
|
return value === null || typeof value !== 'object';
|
|
10122
10220
|
}
|
|
10123
10221
|
|
|
10124
|
-
},{"type-detect":
|
|
10222
|
+
},{"type-detect":39}],37:[function(require,module,exports){
|
|
10125
10223
|
'use strict';
|
|
10126
10224
|
|
|
10127
10225
|
/* !
|
|
@@ -10167,7 +10265,7 @@ function getFuncName(aFunc) {
|
|
|
10167
10265
|
|
|
10168
10266
|
module.exports = getFuncName;
|
|
10169
10267
|
|
|
10170
|
-
},{}],
|
|
10268
|
+
},{}],38:[function(require,module,exports){
|
|
10171
10269
|
'use strict';
|
|
10172
10270
|
|
|
10173
10271
|
/* !
|
|
@@ -10460,7 +10558,7 @@ module.exports = {
|
|
|
10460
10558
|
setPathValue: setPathValue,
|
|
10461
10559
|
};
|
|
10462
10560
|
|
|
10463
|
-
},{}],
|
|
10561
|
+
},{}],39:[function(require,module,exports){
|
|
10464
10562
|
(function (global, factory) {
|
|
10465
10563
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
10466
10564
|
typeof define === 'function' && define.amd ? define(factory) :
|
package/index.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import chai from './index.js';
|
|
2
|
+
|
|
3
|
+
export const expect = chai.expect;
|
|
4
|
+
export const version = chai.version;
|
|
5
|
+
export const AssertionError = chai.AssertionError;
|
|
6
|
+
export const util = chai.util;
|
|
7
|
+
export const config = chai.config;
|
|
8
|
+
export const use = chai.use;
|
|
9
|
+
export const should = chai.should;
|
|
10
|
+
export const assert = chai.assert;
|
|
11
|
+
export const core = chai.core;
|
|
12
|
+
|
|
13
|
+
export default chai;
|
package/karma.conf.js
CHANGED
|
@@ -10,7 +10,13 @@ module.exports = function(config) {
|
|
|
10
10
|
, colors: true
|
|
11
11
|
, logLevel: config.LOG_INFO
|
|
12
12
|
, autoWatch: false
|
|
13
|
-
, browsers: [ '
|
|
13
|
+
, browsers: [ 'HeadlessChrome' ]
|
|
14
|
+
, customLaunchers: {
|
|
15
|
+
HeadlessChrome: {
|
|
16
|
+
base: 'ChromeHeadless'
|
|
17
|
+
, flags: [ '--no-sandbox',]
|
|
18
|
+
, }
|
|
19
|
+
, }
|
|
14
20
|
, browserDisconnectTimeout: 10000
|
|
15
21
|
, browserDisconnectTolerance: 2
|
|
16
22
|
, browserNoActivityTimeout: 20000
|
package/karma.sauce.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = function(config) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
config.browsers = config.browsers.concat(browsers);
|
|
29
|
-
config.customLaunchers
|
|
29
|
+
Object.assign(config.customLaunchers, browserConfig);
|
|
30
30
|
config.reporters.push('saucelabs');
|
|
31
31
|
config.captureTimeout = 300000;
|
|
32
32
|
|
package/lib/chai/assertion.js
CHANGED
|
@@ -138,11 +138,21 @@ module.exports = function (_chai, util) {
|
|
|
138
138
|
if (!ok) {
|
|
139
139
|
msg = util.getMessage(this, arguments);
|
|
140
140
|
var actual = util.getActual(this, arguments);
|
|
141
|
-
|
|
141
|
+
var assertionErrorObjectProperties = {
|
|
142
142
|
actual: actual
|
|
143
143
|
, expected: expected
|
|
144
144
|
, showDiff: showDiff
|
|
145
|
-
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
var operator = util.getOperator(this, arguments);
|
|
148
|
+
if (operator) {
|
|
149
|
+
assertionErrorObjectProperties.operator = operator;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
throw new AssertionError(
|
|
153
|
+
msg,
|
|
154
|
+
assertionErrorObjectProperties,
|
|
155
|
+
(config.includeStack) ? this.assert : flag(this, 'ssfi'));
|
|
146
156
|
}
|
|
147
157
|
};
|
|
148
158
|
|
|
@@ -533,8 +533,13 @@ module.exports = function (chai, _) {
|
|
|
533
533
|
// objects with a custom `@@toStringTag`.
|
|
534
534
|
if (val !== Object(val)) {
|
|
535
535
|
throw new AssertionError(
|
|
536
|
-
flagMsg + '
|
|
537
|
-
|
|
536
|
+
flagMsg + 'the given combination of arguments ('
|
|
537
|
+
+ objType + ' and '
|
|
538
|
+
+ _.type(val).toLowerCase() + ')'
|
|
539
|
+
+ ' is invalid for this assertion. '
|
|
540
|
+
+ 'You can use an array, a map, an object, a set, a string, '
|
|
541
|
+
+ 'or a weakset instead of a '
|
|
542
|
+
+ _.type(val).toLowerCase(),
|
|
538
543
|
undefined,
|
|
539
544
|
ssfi
|
|
540
545
|
);
|
|
@@ -939,7 +944,7 @@ module.exports = function (chai, _) {
|
|
|
939
944
|
*
|
|
940
945
|
* Add `.not` earlier in the chain to negate `.arguments`. However, it's often
|
|
941
946
|
* best to assert which type the target is expected to be, rather than
|
|
942
|
-
* asserting that
|
|
947
|
+
* asserting that it’s not an `arguments` object.
|
|
943
948
|
*
|
|
944
949
|
* expect('foo').to.be.a('string'); // Recommended
|
|
945
950
|
* expect('foo').to.not.be.arguments; // Not recommended
|
|
@@ -1921,7 +1926,7 @@ module.exports = function (chai, _) {
|
|
|
1921
1926
|
* a `descriptor`. The problem is that it creates uncertain expectations by
|
|
1922
1927
|
* asserting that the target either doesn't have a property descriptor with
|
|
1923
1928
|
* the given key `name`, or that it does have a property descriptor with the
|
|
1924
|
-
* given key `name` but
|
|
1929
|
+
* given key `name` but it’s not deeply equal to the given `descriptor`. It's
|
|
1925
1930
|
* often best to identify the exact output that's expected, and then write an
|
|
1926
1931
|
* assertion that only accepts that exact output.
|
|
1927
1932
|
*
|
|
@@ -2950,8 +2955,9 @@ module.exports = function (chai, _) {
|
|
|
2950
2955
|
new Assertion(obj, flagMsg, ssfi, true).is.a('number');
|
|
2951
2956
|
if (typeof expected !== 'number' || typeof delta !== 'number') {
|
|
2952
2957
|
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2958
|
+
var deltaMessage = delta === undefined ? ", and a delta is required" : "";
|
|
2953
2959
|
throw new AssertionError(
|
|
2954
|
-
flagMsg + 'the arguments to closeTo or approximately must be numbers',
|
|
2960
|
+
flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
|
|
2955
2961
|
undefined,
|
|
2956
2962
|
ssfi
|
|
2957
2963
|
);
|
|
@@ -3117,6 +3123,14 @@ module.exports = function (chai, _) {
|
|
|
3117
3123
|
* expect(1).to.equal(1); // Recommended
|
|
3118
3124
|
* expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended
|
|
3119
3125
|
*
|
|
3126
|
+
* It can also be chained with `.contain` or `.include`, which will work with
|
|
3127
|
+
* both arrays and strings:
|
|
3128
|
+
*
|
|
3129
|
+
* expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
|
|
3130
|
+
* expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
|
|
3131
|
+
* expect([1,2,3]).to.contain.oneOf([3,4,5])
|
|
3132
|
+
* expect([1,2,3]).to.not.contain.oneOf([4,5,6])
|
|
3133
|
+
*
|
|
3120
3134
|
* `.oneOf` accepts an optional `msg` argument which is a custom error message
|
|
3121
3135
|
* to show when the assertion fails. The message can also be given as the
|
|
3122
3136
|
* second argument to `expect`.
|
|
@@ -3135,16 +3149,27 @@ module.exports = function (chai, _) {
|
|
|
3135
3149
|
if (msg) flag(this, 'message', msg);
|
|
3136
3150
|
var expected = flag(this, 'object')
|
|
3137
3151
|
, flagMsg = flag(this, 'message')
|
|
3138
|
-
, ssfi = flag(this, 'ssfi')
|
|
3152
|
+
, ssfi = flag(this, 'ssfi')
|
|
3153
|
+
, contains = flag(this, 'contains');
|
|
3139
3154
|
new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
|
|
3140
3155
|
|
|
3141
|
-
|
|
3156
|
+
if (contains) {
|
|
3157
|
+
this.assert(
|
|
3158
|
+
list.some(function(possibility) { return expected.indexOf(possibility) > -1 })
|
|
3159
|
+
, 'expected #{this} to contain one of #{exp}'
|
|
3160
|
+
, 'expected #{this} to not contain one of #{exp}'
|
|
3161
|
+
, list
|
|
3162
|
+
, expected
|
|
3163
|
+
);
|
|
3164
|
+
} else {
|
|
3165
|
+
this.assert(
|
|
3142
3166
|
list.indexOf(expected) > -1
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3167
|
+
, 'expected #{this} to be one of #{exp}'
|
|
3168
|
+
, 'expected #{this} to not be one of #{exp}'
|
|
3169
|
+
, list
|
|
3170
|
+
, expected
|
|
3171
|
+
);
|
|
3172
|
+
}
|
|
3148
3173
|
}
|
|
3149
3174
|
|
|
3150
3175
|
Assertion.addMethod('oneOf', oneOf);
|
|
@@ -1826,7 +1826,7 @@ module.exports = function (chai, util) {
|
|
|
1826
1826
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]);
|
|
1827
1827
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
|
|
1828
1828
|
*
|
|
1829
|
-
* @name
|
|
1829
|
+
* @name hasAnyDeepKeys
|
|
1830
1830
|
* @param {Mixed} object
|
|
1831
1831
|
* @param {Array|Object} keys
|
|
1832
1832
|
* @param {String} message
|
|
@@ -13,7 +13,8 @@ module.exports = function (chai, util) {
|
|
|
13
13
|
if (this instanceof String
|
|
14
14
|
|| this instanceof Number
|
|
15
15
|
|| this instanceof Boolean
|
|
16
|
-
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
16
|
+
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
17
|
+
|| typeof BigInt === 'function' && this instanceof BigInt) {
|
|
17
18
|
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
18
19
|
}
|
|
19
20
|
return new Assertion(this, null, shouldGetter);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var type = require('type-detect');
|
|
2
|
+
|
|
3
|
+
var flag = require('./flag');
|
|
4
|
+
|
|
5
|
+
function isObjectType(obj) {
|
|
6
|
+
var objectType = type(obj);
|
|
7
|
+
var objectTypes = ['Array', 'Object', 'function'];
|
|
8
|
+
|
|
9
|
+
return objectTypes.indexOf(objectType) !== -1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ### .getOperator(message)
|
|
14
|
+
*
|
|
15
|
+
* Extract the operator from error message.
|
|
16
|
+
* Operator defined is based on below link
|
|
17
|
+
* https://nodejs.org/api/assert.html#assert_assert.
|
|
18
|
+
*
|
|
19
|
+
* Returns the `operator` or `undefined` value for an Assertion.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} object (constructed Assertion)
|
|
22
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
|
23
|
+
* @namespace Utils
|
|
24
|
+
* @name getOperator
|
|
25
|
+
* @api public
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
module.exports = function getOperator(obj, args) {
|
|
29
|
+
var operator = flag(obj, 'operator');
|
|
30
|
+
var negate = flag(obj, 'negate');
|
|
31
|
+
var expected = args[3];
|
|
32
|
+
var msg = negate ? args[2] : args[1];
|
|
33
|
+
|
|
34
|
+
if (operator) {
|
|
35
|
+
return operator;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (typeof msg === 'function') msg = msg();
|
|
39
|
+
|
|
40
|
+
msg = msg || '';
|
|
41
|
+
if (!msg) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (/\shave\s/.test(msg)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var isObject = isObjectType(expected);
|
|
50
|
+
if (/\snot\s/.test(msg)) {
|
|
51
|
+
return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
|
55
|
+
};
|
package/lib/chai/utils/index.js
CHANGED
package/lib/chai.js
CHANGED
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"Veselin Todorov <hi@vesln.com>",
|
|
18
18
|
"John Firebaugh <john.firebaugh@gmail.com>"
|
|
19
19
|
],
|
|
20
|
-
"version": "4.
|
|
20
|
+
"version": "4.3.0",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "https://github.com/chaijs/chai"
|
|
@@ -26,11 +26,18 @@
|
|
|
26
26
|
"url": "https://github.com/chaijs/chai/issues"
|
|
27
27
|
},
|
|
28
28
|
"main": "./index",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"require": "./index.js",
|
|
32
|
+
"import": "./index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./": "./"
|
|
35
|
+
},
|
|
29
36
|
"scripts": {
|
|
30
37
|
"test": "make test"
|
|
31
38
|
},
|
|
32
39
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
40
|
+
"node": ">=8"
|
|
34
41
|
},
|
|
35
42
|
"dependencies": {
|
|
36
43
|
"assertion-error": "^1.1.0",
|
|
@@ -41,15 +48,15 @@
|
|
|
41
48
|
"type-detect": "^4.0.5"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
44
|
-
"browserify": "^16.
|
|
51
|
+
"browserify": "^16.2.3",
|
|
45
52
|
"bump-cli": "^1.1.3",
|
|
46
53
|
"codecov": "^3.0.0",
|
|
47
54
|
"istanbul": "^0.4.3",
|
|
48
55
|
"karma": "^2.0.0",
|
|
56
|
+
"karma-chrome-launcher": "^2.2.0",
|
|
49
57
|
"karma-firefox-launcher": "^1.0.0",
|
|
50
58
|
"karma-mocha": "^1.0.1",
|
|
51
|
-
"karma-phantomjs-launcher": "^1.0.0",
|
|
52
59
|
"karma-sauce-launcher": "^1.2.0",
|
|
53
|
-
"mocha": "^
|
|
60
|
+
"mocha": "^7.1.2"
|
|
54
61
|
}
|
|
55
62
|
}
|