@vitest/expect 4.1.0 → 4.1.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.
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9 -5
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -793,13 +793,13 @@ interface ChaiMockAssertion {
|
|
|
793
793
|
*/
|
|
794
794
|
nthCalledWith: <E extends any[]>(n: number, ...args: E) => void;
|
|
795
795
|
/**
|
|
796
|
-
* Checks that a spy returned
|
|
797
|
-
* Chai-style equivalent of `
|
|
796
|
+
* Checks that a spy returned a specific value at least once.
|
|
797
|
+
* Chai-style equivalent of `toHaveReturnedWith`.
|
|
798
798
|
*
|
|
799
799
|
* @example
|
|
800
|
-
* expect(spy).to.have.returned
|
|
800
|
+
* expect(spy).to.have.returned('value')
|
|
801
801
|
*/
|
|
802
|
-
|
|
802
|
+
returned: <E>(value: E) => void;
|
|
803
803
|
/**
|
|
804
804
|
* Checks that a spy returned a specific value at least once.
|
|
805
805
|
* Chai-style equivalent of `toHaveReturnedWith`.
|
package/dist/index.js
CHANGED
|
@@ -28,17 +28,18 @@ const ChaiStyleAssertions = (chai, utils) => {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
function defMethod(name, delegateTo) {
|
|
31
|
-
utils.
|
|
31
|
+
utils.addMethod(chai.Assertion.prototype, name, function(...args) {
|
|
32
32
|
const jestMethod = chai.Assertion.prototype[delegateTo];
|
|
33
33
|
if (!jestMethod) {
|
|
34
34
|
throw new Error(`Cannot delegate to ${String(delegateTo)}: method not found. Ensure JestChaiExpect plugin is loaded first.`);
|
|
35
35
|
}
|
|
36
36
|
return jestMethod.call(this, ...args);
|
|
37
|
-
}
|
|
37
|
+
});
|
|
38
38
|
}
|
|
39
|
+
// API to (somewhat) mirror sinon-chai
|
|
40
|
+
// https://github.com/chaijs/sinon-chai
|
|
39
41
|
defProperty("called", "toHaveBeenCalled");
|
|
40
42
|
defProperty("calledOnce", "toHaveBeenCalledOnce");
|
|
41
|
-
defProperty("returned", "toHaveReturned");
|
|
42
43
|
defPropertyWithArgs("calledTwice", "toHaveBeenCalledTimes", 2);
|
|
43
44
|
defPropertyWithArgs("calledThrice", "toHaveBeenCalledTimes", 3);
|
|
44
45
|
defMethod("callCount", "toHaveBeenCalledTimes");
|
|
@@ -46,12 +47,15 @@ const ChaiStyleAssertions = (chai, utils) => {
|
|
|
46
47
|
defMethod("calledOnceWith", "toHaveBeenCalledExactlyOnceWith");
|
|
47
48
|
defMethod("lastCalledWith", "toHaveBeenLastCalledWith");
|
|
48
49
|
defMethod("nthCalledWith", "toHaveBeenNthCalledWith");
|
|
50
|
+
defMethod("returned", "toHaveReturned");
|
|
49
51
|
defMethod("returnedWith", "toHaveReturnedWith");
|
|
50
52
|
defMethod("returnedTimes", "toHaveReturnedTimes");
|
|
51
53
|
defMethod("lastReturnedWith", "toHaveLastReturnedWith");
|
|
52
54
|
defMethod("nthReturnedWith", "toHaveNthReturnedWith");
|
|
53
55
|
defMethod("calledBefore", "toHaveBeenCalledBefore");
|
|
54
56
|
defMethod("calledAfter", "toHaveBeenCalledAfter");
|
|
57
|
+
// TODO: implement
|
|
58
|
+
// defMethod('thrown', 'toHaveThrown')
|
|
55
59
|
};
|
|
56
60
|
|
|
57
61
|
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
@@ -1733,7 +1737,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1733
1737
|
}
|
|
1734
1738
|
throw err;
|
|
1735
1739
|
});
|
|
1736
|
-
return recordAsyncExpect(test, promise, createAssertionMessage(utils, this, !!args.length), error);
|
|
1740
|
+
return recordAsyncExpect(test, promise, createAssertionMessage(utils, this, !!args.length), error, utils.flag(this, "soft"));
|
|
1737
1741
|
};
|
|
1738
1742
|
} });
|
|
1739
1743
|
return proxy;
|
|
@@ -1774,7 +1778,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1774
1778
|
}
|
|
1775
1779
|
throw err;
|
|
1776
1780
|
});
|
|
1777
|
-
return recordAsyncExpect(test, promise, createAssertionMessage(utils, this, !!args.length), error);
|
|
1781
|
+
return recordAsyncExpect(test, promise, createAssertionMessage(utils, this, !!args.length), error, utils.flag(this, "soft"));
|
|
1778
1782
|
};
|
|
1779
1783
|
} });
|
|
1780
1784
|
return proxy;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/expect",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.1",
|
|
5
5
|
"description": "Jest's expect matchers as a Chai plugin",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@types/chai": "^5.2.2",
|
|
40
40
|
"chai": "^6.2.2",
|
|
41
41
|
"tinyrainbow": "^3.0.3",
|
|
42
|
-
"@vitest/spy": "4.1.
|
|
43
|
-
"@vitest/utils": "4.1.
|
|
42
|
+
"@vitest/spy": "4.1.1",
|
|
43
|
+
"@vitest/utils": "4.1.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@vitest/runner": "4.1.
|
|
46
|
+
"@vitest/runner": "4.1.1"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "premove dist && rollup -c",
|