chai 4.3.7 → 5.0.0-alpha.1

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.
Files changed (44) hide show
  1. package/History.md +1 -1
  2. package/README.md +3 -36
  3. package/chai.js +4190 -11272
  4. package/index.js +1 -1
  5. package/{karma.conf.js → karma.conf.cjs} +3 -3
  6. package/lib/chai/assertion.js +150 -163
  7. package/lib/chai/config.js +1 -1
  8. package/lib/chai/core/assertions.js +3634 -3634
  9. package/lib/chai/interface/assert.js +3035 -3042
  10. package/lib/chai/interface/expect.js +39 -37
  11. package/lib/chai/interface/should.js +203 -204
  12. package/lib/chai/utils/addChainableMethod.js +8 -8
  13. package/lib/chai/utils/addLengthGuard.js +3 -3
  14. package/lib/chai/utils/addMethod.js +8 -8
  15. package/lib/chai/utils/addProperty.js +7 -7
  16. package/lib/chai/utils/compareByInspect.js +3 -3
  17. package/lib/chai/utils/expectTypes.js +5 -5
  18. package/lib/chai/utils/flag.js +2 -2
  19. package/lib/chai/utils/getActual.js +2 -2
  20. package/lib/chai/utils/getMessage.js +5 -5
  21. package/lib/chai/utils/getOperator.js +4 -4
  22. package/lib/chai/utils/getOwnEnumerableProperties.js +3 -3
  23. package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +2 -2
  24. package/lib/chai/utils/getProperties.js +2 -2
  25. package/lib/chai/utils/index.js +30 -34
  26. package/lib/chai/utils/inspect.js +4 -7
  27. package/lib/chai/utils/isNaN.js +2 -2
  28. package/lib/chai/utils/isProxyEnabled.js +3 -3
  29. package/lib/chai/utils/objDisplay.js +5 -4
  30. package/lib/chai/utils/overwriteChainableMethod.js +6 -6
  31. package/lib/chai/utils/overwriteMethod.js +8 -8
  32. package/lib/chai/utils/overwriteProperty.js +7 -7
  33. package/lib/chai/utils/proxify.js +7 -7
  34. package/lib/chai/utils/test.js +4 -4
  35. package/lib/chai/utils/transferFlags.js +2 -2
  36. package/lib/chai.js +29 -28
  37. package/package.json +22 -20
  38. package/register-assert.cjs +3 -0
  39. package/register-assert.js +3 -1
  40. package/register-expect.cjs +3 -0
  41. package/register-expect.js +3 -1
  42. package/register-should.cjs +3 -0
  43. package/register-should.js +3 -1
  44. package/index.mjs +0 -14
package/lib/chai.js CHANGED
@@ -4,25 +4,28 @@
4
4
  * MIT Licensed
5
5
  */
6
6
 
7
- var used = [];
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';
15
+
16
+ const used = [];
8
17
 
9
18
  /*!
10
19
  * Chai version
11
20
  */
12
21
 
13
- exports.version = '4.3.3';
22
+ export const version = '4.3.3';
14
23
 
15
24
  /*!
16
25
  * Assertion Error
17
26
  */
18
27
 
19
- exports.AssertionError = require('assertion-error');
20
-
21
- /*!
22
- * Utils for plugins (not exported)
23
- */
24
-
25
- var util = require('./chai/utils');
28
+ export {AssertionError};
26
29
 
27
30
  /**
28
31
  * # .use(function)
@@ -34,7 +37,17 @@ var util = require('./chai/utils');
34
37
  * @api public
35
38
  */
36
39
 
37
- exports.use = function (fn) {
40
+ export function use(fn) {
41
+ const exports = {
42
+ AssertionError,
43
+ util,
44
+ config,
45
+ expect,
46
+ assert,
47
+ Assertion,
48
+ ...should
49
+ };
50
+
38
51
  if (!~used.indexOf(fn)) {
39
52
  fn(exports, util);
40
53
  used.push(fn);
@@ -47,46 +60,34 @@ exports.use = function (fn) {
47
60
  * Utility Functions
48
61
  */
49
62
 
50
- exports.util = util;
63
+ export {util};
51
64
 
52
65
  /*!
53
66
  * Configuration
54
67
  */
55
68
 
56
- var config = require('./chai/config');
57
- exports.config = config;
69
+ export {config};
58
70
 
59
71
  /*!
60
72
  * Primary `Assertion` prototype
61
73
  */
62
74
 
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);
75
+ export * from './chai/assertion.js';
72
76
 
73
77
  /*!
74
78
  * Expect interface
75
79
  */
76
80
 
77
- var expect = require('./chai/interface/expect');
78
- exports.use(expect);
81
+ export * from './chai/interface/expect.js';
79
82
 
80
83
  /*!
81
84
  * Should interface
82
85
  */
83
86
 
84
- var should = require('./chai/interface/should');
85
- exports.use(should);
87
+ export * from './chai/interface/should.js';
86
88
 
87
89
  /*!
88
90
  * Assert interface
89
91
  */
90
92
 
91
- var assert = require('./chai/interface/assert');
92
- exports.use(assert);
93
+ 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": "4.3.7",
21
+ "version": "5.0.0-alpha.1",
21
22
  "repository": {
22
23
  "type": "git",
23
24
  "url": "https://github.com/chaijs/chai"
@@ -25,39 +26,40 @@
25
26
  "bugs": {
26
27
  "url": "https://github.com/chaijs/chai/issues"
27
28
  },
28
- "main": "./index",
29
- "exports": {
30
- ".": {
31
- "require": "./index.js",
32
- "import": "./index.mjs"
33
- },
34
- "./*": "./*"
35
- },
29
+ "main": "./chai.js",
36
30
  "scripts": {
37
- "test": "make test"
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 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": "karma start karma.conf.cjs --single-run --browsers HeadlessChrome",
38
+ "test-firefox": "karma start karma.conf.cjs --browsers Firefox",
39
+ "test-cov": "istanbul cover ./node_modules/.bin/_mocha -- --require ./test/bootstrap/index.js test/*.js",
40
+ "clean": "rm -f chai.js coverage"
38
41
  },
39
42
  "engines": {
40
- "node": ">=4"
43
+ "node": ">=12"
41
44
  },
42
45
  "dependencies": {
43
46
  "assertion-error": "^1.1.0",
44
- "check-error": "^1.0.2",
47
+ "check-error": "^2.0.0",
45
48
  "deep-eql": "^4.1.2",
46
- "get-func-name": "^2.0.0",
47
49
  "loupe": "^2.3.1",
48
- "pathval": "^1.1.1",
50
+ "pathval": "^2.0.0",
49
51
  "type-detect": "^4.0.5"
50
52
  },
51
53
  "devDependencies": {
52
- "browserify": "^16.2.3",
53
54
  "bump-cli": "^1.1.3",
54
- "codecov": "^3.0.0",
55
+ "codecov": "^3.8.1",
56
+ "esbuild": "^0.17.3",
55
57
  "istanbul": "^0.4.3",
56
58
  "karma": "^6.1.1",
57
- "karma-chrome-launcher": "^2.2.0",
58
- "karma-firefox-launcher": "^1.0.0",
59
+ "karma-chrome-launcher": "^3.1.0",
60
+ "karma-firefox-launcher": "^2.1.0",
59
61
  "karma-mocha": "^2.0.1",
60
- "karma-sauce-launcher": "^1.2.0",
61
- "mocha": "^7.1.2"
62
+ "karma-sauce-launcher": "^4.3.5",
63
+ "mocha": "^8.3.0"
62
64
  }
63
65
  }
@@ -0,0 +1,3 @@
1
+ const {assert} = require('./chai.cjs');
2
+
3
+ globalThis.assert = assert;
@@ -1 +1,3 @@
1
- global.assert = require('./').assert;
1
+ import {assert} from './index.js';
2
+
3
+ globalThis.assert = assert;
@@ -0,0 +1,3 @@
1
+ const {expect} = require('./chai.cjs');
2
+
3
+ globalThis.expect = expect;
@@ -1 +1,3 @@
1
- global.expect = require('./').expect;
1
+ import {expect} from './index.js';
2
+
3
+ globalThis.expect = expect;
@@ -0,0 +1,3 @@
1
+ const {should} = require('./chai.cjs');
2
+
3
+ globalThis.should = should();
@@ -1 +1,3 @@
1
- global.should = require('./').should();
1
+ import {should} from './index.js';
2
+
3
+ globalThis.should = should();
package/index.mjs DELETED
@@ -1,14 +0,0 @@
1
- import chai from './index.js';
2
-
3
- export const expect = chai.expect;
4
- export const version = chai.version;
5
- export const Assertion = chai.Assertion;
6
- export const AssertionError = chai.AssertionError;
7
- export const util = chai.util;
8
- export const config = chai.config;
9
- export const use = chai.use;
10
- export const should = chai.should;
11
- export const assert = chai.assert;
12
- export const core = chai.core;
13
-
14
- export default chai;