@vitest/expect
Advanced tools
Comparing version 1.0.0-beta.4 to 1.0.0-beta.5
@@ -61,2 +61,3 @@ import { stringify, Constructable } from '@vitest/utils'; | ||
interface MatcherState { | ||
customTesters: Array<Tester>; | ||
assertionCalls: number; | ||
@@ -63,0 +64,0 @@ currentTestName?: string; |
@@ -433,2 +433,3 @@ import { getColors, stringify, isObject, assertTypes } from '@vitest/utils'; | ||
isNot: this.inverse, | ||
customTesters: [], | ||
utils: { | ||
@@ -852,2 +853,28 @@ ...getMatcherUtils(), | ||
def("toContain", function(item) { | ||
const actual = this._obj; | ||
if (typeof Node !== "undefined" && actual instanceof Node) { | ||
if (!(item instanceof Node)) | ||
throw new TypeError(`toContain() expected a DOM node as the argument, but got ${typeof item}`); | ||
return this.assert( | ||
actual.contains(item), | ||
"expected #{this} to contain element #{exp}", | ||
"expected #{this} not to contain element #{exp}", | ||
item, | ||
actual | ||
); | ||
} | ||
if (typeof DOMTokenList !== "undefined" && actual instanceof DOMTokenList) { | ||
assertTypes(item, "class name", ["string"]); | ||
const isNot = utils.flag(this, "negate"); | ||
const expectedClassList = isNot ? actual.value.replace(item, "").trim() : `${actual.value} ${item}`; | ||
return this.assert( | ||
actual.contains(item), | ||
`expected "${actual.value}" to contain "${item}"`, | ||
`expected "${actual.value}" not to contain "${item}"`, | ||
expectedClassList, | ||
actual.value | ||
); | ||
} | ||
if (actual != null && typeof actual !== "string") | ||
utils.flag(this, "object", Array.from(actual)); | ||
return this.contain(item); | ||
@@ -1337,2 +1364,3 @@ }); | ||
); | ||
_error.cause = err; | ||
_error.stack = error.stack.replace(error.message, _error.message); | ||
@@ -1367,3 +1395,3 @@ throw _error; | ||
`promise resolved "${utils.inspect(value)}" instead of rejecting`, | ||
{ showDiff: false } | ||
{ showDiff: true, expected: new Error("rejected promise"), actual: value } | ||
); | ||
@@ -1399,2 +1427,4 @@ _error.stack = error.stack.replace(error.message, _error.message); | ||
...getState(expect), | ||
// TODO: implement via expect.addEqualityTesters | ||
customTesters: [], | ||
isNot, | ||
@@ -1401,0 +1431,0 @@ utils: jestUtils, |
{ | ||
"name": "@vitest/expect", | ||
"type": "module", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0-beta.5", | ||
"description": "Jest's expect matchers as a Chai plugin", | ||
@@ -21,3 +21,3 @@ "license": "MIT", | ||
"types": "./index.d.ts", | ||
"import": "./dist/index.js" | ||
"default": "./dist/index.js" | ||
}, | ||
@@ -30,9 +30,9 @@ "./*": "./*" | ||
"files": [ | ||
"dist", | ||
"*.d.ts" | ||
"*.d.ts", | ||
"dist" | ||
], | ||
"dependencies": { | ||
"chai": "^4.3.10", | ||
"@vitest/spy": "1.0.0-beta.4", | ||
"@vitest/utils": "1.0.0-beta.4" | ||
"@vitest/spy": "1.0.0-beta.5", | ||
"@vitest/utils": "1.0.0-beta.5" | ||
}, | ||
@@ -43,3 +43,3 @@ "devDependencies": { | ||
"rollup-plugin-copy": "^3.5.0", | ||
"@vitest/runner": "1.0.0-beta.4" | ||
"@vitest/runner": "1.0.0-beta.5" | ||
}, | ||
@@ -46,0 +46,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136922
7
1755
5
+ Added@vitest/spy@1.0.0-beta.5(transitive)
+ Added@vitest/utils@1.0.0-beta.5(transitive)
- Removed@vitest/spy@1.0.0-beta.4(transitive)
- Removed@vitest/utils@1.0.0-beta.4(transitive)
Updated@vitest/spy@1.0.0-beta.5
Updated@vitest/utils@1.0.0-beta.5