chai 4.3.10 → 5.0.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.
Files changed (46) hide show
  1. package/CONTRIBUTING.md +7 -1
  2. package/README.md +3 -43
  3. package/chai.js +3802 -11206
  4. package/index.js +1 -1
  5. package/{karma.conf.js → karma.conf.cjs} +4 -3
  6. package/lib/chai/assertion.js +153 -163
  7. package/lib/chai/config.js +28 -2
  8. package/lib/chai/core/assertions.js +3631 -3634
  9. package/lib/chai/interface/assert.js +3036 -3042
  10. package/lib/chai/interface/expect.js +40 -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 +5 -6
  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 +4 -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 +3 -3
  35. package/lib/chai/utils/transferFlags.js +2 -2
  36. package/lib/chai/utils/type-detect.js +16 -0
  37. package/lib/chai.js +27 -32
  38. package/package.json +24 -28
  39. package/register-assert.cjs +3 -0
  40. package/register-assert.js +3 -1
  41. package/register-expect.cjs +3 -0
  42. package/register-expect.js +3 -1
  43. package/register-should.cjs +3 -0
  44. package/register-should.js +3 -1
  45. package/web-test-runner.config.js +17 -0
  46. package/index.mjs +0 -14
package/lib/chai.js CHANGED
@@ -4,25 +4,22 @@
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';
8
15
 
9
- /*!
10
- * Chai version
11
- */
12
-
13
- exports.version = '4.3.8';
16
+ const used = [];
14
17
 
15
18
  /*!
16
19
  * Assertion Error
17
20
  */
18
21
 
19
- exports.AssertionError = require('assertion-error');
20
-
21
- /*!
22
- * Utils for plugins (not exported)
23
- */
24
-
25
- var util = require('./chai/utils');
22
+ export {AssertionError};
26
23
 
27
24
  /**
28
25
  * # .use(function)
@@ -34,7 +31,17 @@ var util = require('./chai/utils');
34
31
  * @api public
35
32
  */
36
33
 
37
- exports.use = function (fn) {
34
+ export function use(fn) {
35
+ const exports = {
36
+ AssertionError,
37
+ util,
38
+ config,
39
+ expect,
40
+ assert,
41
+ Assertion,
42
+ ...should
43
+ };
44
+
38
45
  if (!~used.indexOf(fn)) {
39
46
  fn(exports, util);
40
47
  used.push(fn);
@@ -47,46 +54,34 @@ exports.use = function (fn) {
47
54
  * Utility Functions
48
55
  */
49
56
 
50
- exports.util = util;
57
+ export {util};
51
58
 
52
59
  /*!
53
60
  * Configuration
54
61
  */
55
62
 
56
- var config = require('./chai/config');
57
- exports.config = config;
63
+ export {config};
58
64
 
59
65
  /*!
60
66
  * Primary `Assertion` prototype
61
67
  */
62
68
 
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);
69
+ export * from './chai/assertion.js';
72
70
 
73
71
  /*!
74
72
  * Expect interface
75
73
  */
76
74
 
77
- var expect = require('./chai/interface/expect');
78
- exports.use(expect);
75
+ export * from './chai/interface/expect.js';
79
76
 
80
77
  /*!
81
78
  * Should interface
82
79
  */
83
80
 
84
- var should = require('./chai/interface/should');
85
- exports.use(should);
81
+ export * from './chai/interface/should.js';
86
82
 
87
83
  /*!
88
84
  * Assert interface
89
85
  */
90
86
 
91
- var assert = require('./chai/interface/assert');
92
- exports.use(assert);
87
+ 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.10",
21
+ "version": "5.0.0",
21
22
  "repository": {
22
23
  "type": "git",
23
24
  "url": "https://github.com/chaijs/chai"
@@ -25,39 +26,34 @@
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": "web-test-runner --playwright",
38
+ "clean": "rm -f chai.js coverage"
38
39
  },
39
40
  "engines": {
40
- "node": ">=4"
41
+ "node": ">=12"
41
42
  },
42
43
  "dependencies": {
43
- "assertion-error": "^1.1.0",
44
- "check-error": "^1.0.3",
45
- "deep-eql": "^4.1.3",
46
- "get-func-name": "^2.0.2",
47
- "loupe": "^2.3.6",
48
- "pathval": "^1.1.1",
49
- "type-detect": "^4.0.8"
44
+ "assertion-error": "^2.0.1",
45
+ "check-error": "^2.0.0",
46
+ "deep-eql": "^5.0.1",
47
+ "loupe": "^3.0.0",
48
+ "pathval": "^2.0.0"
50
49
  },
51
50
  "devDependencies": {
52
- "browserify": "^16.5.2",
53
- "bump-cli": "^2.7.1",
54
- "codecov": "^3.8.3",
55
- "istanbul": "^0.4.5",
56
- "karma": "^6.4.2",
57
- "karma-chrome-launcher": "^2.2.0",
58
- "karma-firefox-launcher": "^1.3.0",
59
- "karma-mocha": "^2.0.1",
60
- "karma-sauce-launcher": "^4.1.4",
61
- "mocha": "^10.2.0"
51
+ "@rollup/plugin-commonjs": "^25.0.7",
52
+ "@web/dev-server-rollup": "^0.5.4",
53
+ "@web/test-runner": "^0.17.2",
54
+ "@web/test-runner-playwright": "^0.10.2",
55
+ "bump-cli": "^1.1.3",
56
+ "esbuild": "^0.17.3",
57
+ "mocha": "^8.3.0"
62
58
  }
63
59
  }
@@ -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();
@@ -0,0 +1,17 @@
1
+ import { fromRollup } from "@web/dev-server-rollup";
2
+ import rollupCommonjs from "@rollup/plugin-commonjs";
3
+
4
+ const commonjs = fromRollup(rollupCommonjs);
5
+
6
+ export default {
7
+ nodeResolve: true,
8
+ files: ["test/*.js"],
9
+ plugins: [
10
+ commonjs({
11
+ include: [
12
+ // the commonjs plugin is slow, list the required packages explicitly:
13
+ "**/node_modules/type-detect/**/*",
14
+ ],
15
+ }),
16
+ ],
17
+ };
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;