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/CONTRIBUTING.md
CHANGED
|
@@ -21,6 +21,7 @@ Following these guidelines helps to communicate that you respect the time of the
|
|
|
21
21
|
|
|
22
22
|
- Creating an Issue or Pull Request requires a [GitHub](http://github.com) account.
|
|
23
23
|
- Issue reports should be **clear**, **concise** and **reproducible**. Check to see if your issue has already been resolved in the [master]() branch or already reported in Chai's [GitHub Issue Tracker](https://github.com/chaijs/chai/issues).
|
|
24
|
+
- Pull Requests must adhere to strict [coding style guidelines](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide).
|
|
24
25
|
- In general, avoid submitting PRs for new Assertions without asking core contributors first. More than likely it would be better implemented as a plugin.
|
|
25
26
|
- Additional support is available via the [Google Group](http://groups.google.com/group/chaijs) or on irc.freenode.net#chaijs.
|
|
26
27
|
- **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project.
|
|
@@ -90,7 +91,7 @@ Good pull requests - patches, improvements, new features - are a fantastic help.
|
|
|
90
91
|
|
|
91
92
|
**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
|
|
92
93
|
|
|
93
|
-
Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
|
|
94
|
+
Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). Please review the [Chai.js Coding Style Guide](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide).
|
|
94
95
|
|
|
95
96
|
Follow this process if you'd like your work considered for inclusion in the project:
|
|
96
97
|
|
|
@@ -184,6 +185,11 @@ For most of the documentation you are going to want to visit [ChaiJS.com](http:/
|
|
|
184
185
|
- [API Reference](http://chaijs.com/api/)
|
|
185
186
|
- [Plugins](http://chaijs.com/plugins/)
|
|
186
187
|
|
|
188
|
+
Alternatively, the [wiki](https://github.com/chaijs/chai/wiki) might be what you are looking for.
|
|
189
|
+
|
|
190
|
+
- [Chai Coding Style Guide](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide)
|
|
191
|
+
- [Third-party Resources](https://github.com/chaijs/chai/wiki/Third-Party-Resources)
|
|
192
|
+
|
|
187
193
|
Or finally, you may find a core-contributor or like-minded developer in any of our support channels.
|
|
188
194
|
|
|
189
195
|
- IRC: irc.freenode.org #chaijs
|
package/README.md
CHANGED
|
@@ -11,54 +11,16 @@
|
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<p align=center>
|
|
14
|
-
<a href="./LICENSE">
|
|
15
|
-
<img
|
|
16
|
-
alt="license:mit"
|
|
17
|
-
src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square"
|
|
18
|
-
/>
|
|
19
|
-
</a>
|
|
20
|
-
<a href="https://github.com/chaijs/chai/releases">
|
|
21
|
-
<img
|
|
22
|
-
alt="tag:?"
|
|
23
|
-
src="https://img.shields.io/github/tag/chaijs/chai.svg?style=flat-square"
|
|
24
|
-
/>
|
|
25
|
-
</a>
|
|
26
14
|
<a href="https://www.npmjs.com/package/chai">
|
|
27
|
-
<img
|
|
28
|
-
alt="node:?"
|
|
29
|
-
src="https://img.shields.io/badge/node-%3E=4.0-blue.svg?style=flat-square"
|
|
30
|
-
/>
|
|
31
|
-
</a>
|
|
32
|
-
<br/>
|
|
33
|
-
<a href="https://saucelabs.com/u/chaijs">
|
|
34
|
-
<img
|
|
35
|
-
alt="Selenium Test Status"
|
|
36
|
-
src="https://saucelabs.com/browser-matrix/chaijs.svg"
|
|
37
|
-
/>
|
|
38
|
-
</a>
|
|
39
|
-
<br/>
|
|
40
|
-
<a href="https://www.npmjs.com/packages/chai">
|
|
41
15
|
<img
|
|
42
16
|
alt="downloads:?"
|
|
43
17
|
src="https://img.shields.io/npm/dm/chai.svg?style=flat-square"
|
|
44
18
|
/>
|
|
45
19
|
</a>
|
|
46
|
-
<a href="https://
|
|
47
|
-
<img
|
|
48
|
-
alt="build:?"
|
|
49
|
-
src="https://img.shields.io/travis/chaijs/chai/master.svg?style=flat-square"
|
|
50
|
-
/>
|
|
51
|
-
</a>
|
|
52
|
-
<a href="https://codecov.io/gh/chaijs/chai">
|
|
53
|
-
<img
|
|
54
|
-
alt="coverage:?"
|
|
55
|
-
src="https://img.shields.io/codecov/c/github/chaijs/chai.svg?style=flat-square"
|
|
56
|
-
/>
|
|
57
|
-
</a>
|
|
58
|
-
<a href="">
|
|
20
|
+
<a href="https://www.npmjs.com/package/chai">
|
|
59
21
|
<img
|
|
60
|
-
alt="
|
|
61
|
-
src="https://img.shields.io/
|
|
22
|
+
alt="node:?"
|
|
23
|
+
src="https://img.shields.io/badge/node-%3E=4.0-blue.svg?style=flat-square"
|
|
62
24
|
/>
|
|
63
25
|
</a>
|
|
64
26
|
<br/>
|
|
@@ -109,32 +71,12 @@ You can also use it within the browser; install via npm and use the `chai.js` fi
|
|
|
109
71
|
Import the library in your code, and then pick one of the styles you'd like to use - either `assert`, `expect` or `should`:
|
|
110
72
|
|
|
111
73
|
```js
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var should = chai.should(); // Using Should style
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Pre-Native Modules Usage (_registers the chai testing style globally_)
|
|
119
|
-
|
|
120
|
-
```js
|
|
121
|
-
require('chai/register-assert'); // Using Assert style
|
|
122
|
-
require('chai/register-expect'); // Using Expect style
|
|
123
|
-
require('chai/register-should'); // Using Should style
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Pre-Native Modules Usage (_as local variables_)
|
|
127
|
-
|
|
128
|
-
```js
|
|
129
|
-
const { assert } = require('chai'); // Using Assert style
|
|
130
|
-
const { expect } = require('chai'); // Using Expect style
|
|
131
|
-
const { should } = require('chai'); // Using Should style
|
|
132
|
-
should(); // Modifies `Object.prototype`
|
|
133
|
-
|
|
134
|
-
const { expect, use } = require('chai'); // Creates local variables `expect` and `use`; useful for plugin use
|
|
74
|
+
import { assert } from 'chai'; // Using Assert style
|
|
75
|
+
import { expect } from 'chai'; // Using Expect style
|
|
76
|
+
import { should } from 'chai'; // Using Should style
|
|
135
77
|
```
|
|
136
78
|
|
|
137
|
-
###
|
|
79
|
+
### Register the chai testing style globally
|
|
138
80
|
|
|
139
81
|
```js
|
|
140
82
|
import 'chai/register-assert'; // Using Assert style
|
|
@@ -142,21 +84,23 @@ import 'chai/register-expect'; // Using Expect style
|
|
|
142
84
|
import 'chai/register-should'; // Using Should style
|
|
143
85
|
```
|
|
144
86
|
|
|
145
|
-
###
|
|
87
|
+
### Import assertion styles as local variables
|
|
146
88
|
|
|
147
89
|
```js
|
|
148
90
|
import { assert } from 'chai'; // Using Assert style
|
|
149
91
|
import { expect } from 'chai'; // Using Expect style
|
|
150
92
|
import { should } from 'chai'; // Using Should style
|
|
151
93
|
should(); // Modifies `Object.prototype`
|
|
94
|
+
|
|
95
|
+
import { expect, use } from 'chai'; // Creates local variables `expect` and `use`; useful for plugin use
|
|
152
96
|
```
|
|
153
97
|
|
|
154
98
|
### Usage with Mocha
|
|
155
99
|
|
|
156
100
|
```bash
|
|
157
|
-
mocha spec.js
|
|
158
|
-
mocha spec.js
|
|
159
|
-
mocha spec.js
|
|
101
|
+
mocha spec.js --require chai/register-assert.js # Using Assert style
|
|
102
|
+
mocha spec.js --require chai/register-expect.js # Using Expect style
|
|
103
|
+
mocha spec.js --require chai/register-should.js # Using Should style
|
|
160
104
|
```
|
|
161
105
|
|
|
162
106
|
[Read more about these styles in our docs](http://chaijs.com/guide/styles/).
|
|
@@ -177,11 +121,9 @@ Chai offers a robust Plugin architecture for extending Chai's assertions and int
|
|
|
177
121
|
- [chaijs / chai-docs](https://github.com/chaijs/chai-docs): The chaijs.com website source code.
|
|
178
122
|
- [chaijs / assertion-error](https://github.com/chaijs/assertion-error): Custom `Error` constructor thrown upon an assertion failing.
|
|
179
123
|
- [chaijs / deep-eql](https://github.com/chaijs/deep-eql): Improved deep equality testing for Node.js and the browser.
|
|
180
|
-
- [chaijs / type-detect](https://github.com/chaijs/type-detect): Improved typeof detection for Node.js and the browser.
|
|
181
124
|
- [chaijs / check-error](https://github.com/chaijs/check-error): Error comparison and information related utility for Node.js and the browser.
|
|
182
125
|
- [chaijs / loupe](https://github.com/chaijs/loupe): Inspect utility for Node.js and browsers.
|
|
183
126
|
- [chaijs / pathval](https://github.com/chaijs/pathval): Object value retrieval given a string path.
|
|
184
|
-
- [chaijs / get-func-name](https://github.com/chaijs/get-func-name): Utility for getting a function's name for node and the browser.
|
|
185
127
|
|
|
186
128
|
### Contributing
|
|
187
129
|
|