test: avoid deprecated jest.addMatchers (#12811)

This commit is contained in:
Tim Seckinger 2021-02-17 00:36:19 +01:00 committed by GitHub
parent 8e9143f06f
commit 0bb57005c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -342,12 +342,15 @@ function normalizeOutput(code) {
return result;
}
const toEqualFile = () => ({
compare: (actual, { filename, code }) => {
const toEqualFile = (actual, { filename, code }) => {
const pass = actual === code;
return {
pass,
message: () => {
message: pass
? () => {
throw new Error(".toEqualFile does not support negation");
}
: () => {
const diffString = diff(code, actual, {
expand: false,
});
@ -358,11 +361,7 @@ const toEqualFile = () => ({
);
},
};
},
negativeCompare: () => {
throw new Error("Negation unsupported");
},
});
};
export default function (
fixturesLoc: string,
@ -377,7 +376,7 @@ export default function (
if (suiteOpts.ignoreSuites?.includes(testSuite.title)) continue;
describe(name + "/" + testSuite.title, function () {
jest.addMatchers({
expect.extend({
toEqualFile,
});