@vitest/expect 1.0.0-beta.4 → 1.0.0-beta.5
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/dist/index.d.ts +1 -0
- package/dist/index.js +31 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -430,6 +430,7 @@ class AsymmetricMatcher {
|
|
430
430
|
...getState(expect || globalThis[GLOBAL_EXPECT]),
|
431
431
|
equals,
|
432
432
|
isNot: this.inverse,
|
433
|
+
customTesters: [],
|
433
434
|
utils: {
|
434
435
|
...getMatcherUtils(),
|
435
436
|
diff,
|
@@ -848,6 +849,32 @@ const JestChaiExpect = (chai, utils) => {
|
|
848
849
|
return this.match(expected);
|
849
850
|
});
|
850
851
|
def("toContain", function(item) {
|
852
|
+
const actual = this._obj;
|
853
|
+
if (typeof Node !== "undefined" && actual instanceof Node) {
|
854
|
+
if (!(item instanceof Node))
|
855
|
+
throw new TypeError(`toContain() expected a DOM node as the argument, but got ${typeof item}`);
|
856
|
+
return this.assert(
|
857
|
+
actual.contains(item),
|
858
|
+
"expected #{this} to contain element #{exp}",
|
859
|
+
"expected #{this} not to contain element #{exp}",
|
860
|
+
item,
|
861
|
+
actual
|
862
|
+
);
|
863
|
+
}
|
864
|
+
if (typeof DOMTokenList !== "undefined" && actual instanceof DOMTokenList) {
|
865
|
+
assertTypes(item, "class name", ["string"]);
|
866
|
+
const isNot = utils.flag(this, "negate");
|
867
|
+
const expectedClassList = isNot ? actual.value.replace(item, "").trim() : `${actual.value} ${item}`;
|
868
|
+
return this.assert(
|
869
|
+
actual.contains(item),
|
870
|
+
`expected "${actual.value}" to contain "${item}"`,
|
871
|
+
`expected "${actual.value}" not to contain "${item}"`,
|
872
|
+
expectedClassList,
|
873
|
+
actual.value
|
874
|
+
);
|
875
|
+
}
|
876
|
+
if (actual != null && typeof actual !== "string")
|
877
|
+
utils.flag(this, "object", Array.from(actual));
|
851
878
|
return this.contain(item);
|
852
879
|
});
|
853
880
|
def("toContainEqual", function(expected) {
|
@@ -1332,6 +1359,7 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
|
|
1332
1359
|
`promise rejected "${utils.inspect(err)}" instead of resolving`,
|
1333
1360
|
{ showDiff: false }
|
1334
1361
|
);
|
1362
|
+
_error.cause = err;
|
1335
1363
|
_error.stack = error.stack.replace(error.message, _error.message);
|
1336
1364
|
throw _error;
|
1337
1365
|
}
|
@@ -1361,7 +1389,7 @@ Number of calls: ${c().bold(spy.mock.calls.length)}
|
|
1361
1389
|
(value) => {
|
1362
1390
|
const _error = new AssertionError(
|
1363
1391
|
`promise resolved "${utils.inspect(value)}" instead of rejecting`,
|
1364
|
-
{ showDiff:
|
1392
|
+
{ showDiff: true, expected: new Error("rejected promise"), actual: value }
|
1365
1393
|
);
|
1366
1394
|
_error.stack = error.stack.replace(error.message, _error.message);
|
1367
1395
|
throw _error;
|
@@ -1392,6 +1420,8 @@ function getMatcherState(assertion, expect) {
|
|
1392
1420
|
};
|
1393
1421
|
const matcherState = {
|
1394
1422
|
...getState(expect),
|
1423
|
+
// TODO: implement via expect.addEqualityTesters
|
1424
|
+
customTesters: [],
|
1395
1425
|
isNot,
|
1396
1426
|
utils: jestUtils,
|
1397
1427
|
promise,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/expect",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.0.0-beta.
|
4
|
+
"version": "1.0.0-beta.5",
|
5
5
|
"description": "Jest's expect matchers as a Chai plugin",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"exports": {
|
19
19
|
".": {
|
20
20
|
"types": "./index.d.ts",
|
21
|
-
"
|
21
|
+
"default": "./dist/index.js"
|
22
22
|
},
|
23
23
|
"./*": "./*"
|
24
24
|
},
|
@@ -26,19 +26,19 @@
|
|
26
26
|
"module": "./dist/index.js",
|
27
27
|
"types": "./index.d.ts",
|
28
28
|
"files": [
|
29
|
-
"
|
30
|
-
"
|
29
|
+
"*.d.ts",
|
30
|
+
"dist"
|
31
31
|
],
|
32
32
|
"dependencies": {
|
33
33
|
"chai": "^4.3.10",
|
34
|
-
"@vitest/spy": "1.0.0-beta.
|
35
|
-
"@vitest/utils": "1.0.0-beta.
|
34
|
+
"@vitest/spy": "1.0.0-beta.5",
|
35
|
+
"@vitest/utils": "1.0.0-beta.5"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
38
|
"@types/chai": "4.3.6",
|
39
39
|
"picocolors": "^1.0.0",
|
40
40
|
"rollup-plugin-copy": "^3.5.0",
|
41
|
-
"@vitest/runner": "1.0.0-beta.
|
41
|
+
"@vitest/runner": "1.0.0-beta.5"
|
42
42
|
},
|
43
43
|
"scripts": {
|
44
44
|
"build": "rimraf dist && rollup -c",
|