@vitest/expect 4.1.3 → 4.1.4
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 +6 -0
- package/dist/index.js +10 -3
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,12 @@ interface MatcherState {
|
|
|
156
156
|
};
|
|
157
157
|
soft?: boolean;
|
|
158
158
|
poll?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* The same assertion instance that chai plugins receive.
|
|
161
|
+
* @experimental
|
|
162
|
+
* @see {@link https://www.chaijs.com/guide/plugins/} Core Plugin Concepts
|
|
163
|
+
*/
|
|
164
|
+
readonly assertion: Assertion;
|
|
159
165
|
}
|
|
160
166
|
interface SyncExpectationResult {
|
|
161
167
|
pass: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1846,7 +1846,7 @@ function getMatcherState(assertion, expect) {
|
|
|
1846
1846
|
suppressedErrors: [],
|
|
1847
1847
|
soft: util.flag(assertion, "soft"),
|
|
1848
1848
|
poll: util.flag(assertion, "poll"),
|
|
1849
|
-
|
|
1849
|
+
assertion
|
|
1850
1850
|
};
|
|
1851
1851
|
Object.assign(matcherState, { task });
|
|
1852
1852
|
return {
|
|
@@ -1874,7 +1874,7 @@ function JestExtendPlugin(c, expect, matchers) {
|
|
|
1874
1874
|
const thenable = result;
|
|
1875
1875
|
return thenable.then(({ pass, message, actual, expected, meta }) => {
|
|
1876
1876
|
if (pass && isNot || !pass && !isNot) {
|
|
1877
|
-
const errorMessage = customMessage
|
|
1877
|
+
const errorMessage = (customMessage ? `${customMessage}: ` : "") + message();
|
|
1878
1878
|
throw new JestExtendError(errorMessage, actual, expected, {
|
|
1879
1879
|
assertionName: expectAssertionName,
|
|
1880
1880
|
meta
|
|
@@ -1884,7 +1884,7 @@ function JestExtendPlugin(c, expect, matchers) {
|
|
|
1884
1884
|
}
|
|
1885
1885
|
const { pass, message, actual, expected, meta } = result;
|
|
1886
1886
|
if (pass && isNot || !pass && !isNot) {
|
|
1887
|
-
const errorMessage = customMessage
|
|
1887
|
+
const errorMessage = (customMessage ? `${customMessage}: ` : "") + message();
|
|
1888
1888
|
throw new JestExtendError(errorMessage, actual, expected, {
|
|
1889
1889
|
assertionName: expectAssertionName,
|
|
1890
1890
|
meta
|
|
@@ -1894,6 +1894,13 @@ function JestExtendPlugin(c, expect, matchers) {
|
|
|
1894
1894
|
const softWrapper = wrapAssertion(utils, expectAssertionName, __VITEST_EXTEND_ASSERTION__);
|
|
1895
1895
|
utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers, expectAssertionName, softWrapper);
|
|
1896
1896
|
utils.addMethod(c.Assertion.prototype, expectAssertionName, softWrapper);
|
|
1897
|
+
// `expect.poll()` inspects the installed Chai assertion method,
|
|
1898
|
+
// so copy the internal marker from the original matcher function.
|
|
1899
|
+
// this is only for domain snapshot matchers for now.
|
|
1900
|
+
if (expectAssertion.__vitest_poll_takeover__) {
|
|
1901
|
+
const addedMethod = c.Assertion.prototype[expectAssertionName];
|
|
1902
|
+
Object.defineProperty(addedMethod, "__vitest_poll_takeover__", { value: true });
|
|
1903
|
+
}
|
|
1897
1904
|
class CustomMatcher extends AsymmetricMatcher {
|
|
1898
1905
|
constructor(inverse = false, ...sample) {
|
|
1899
1906
|
super(sample, inverse);
|
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.4",
|
|
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.1.0",
|
|
42
|
-
"@vitest/spy": "4.1.
|
|
43
|
-
"@vitest/utils": "4.1.
|
|
42
|
+
"@vitest/spy": "4.1.4",
|
|
43
|
+
"@vitest/utils": "4.1.4"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@vitest/runner": "4.1.
|
|
46
|
+
"@vitest/runner": "4.1.4"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "premove dist && rollup -c",
|