New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: avoid deprecated jest.addMatchers #12811
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,27 +342,26 @@ function normalizeOutput(code) { | |
return result; | ||
} | ||
|
||
const toEqualFile = () => ({ | ||
compare: (actual, { filename, code }) => { | ||
const pass = actual === code; | ||
return { | ||
pass, | ||
message: () => { | ||
const diffString = diff(code, actual, { | ||
expand: false, | ||
}); | ||
return ( | ||
`Expected ${filename} to match transform output.\n` + | ||
`To autogenerate a passing version of this file, delete the file and re-run the tests.\n\n` + | ||
`Diff:\n\n${diffString}` | ||
); | ||
}, | ||
}; | ||
}, | ||
negativeCompare: () => { | ||
throw new Error("Negation unsupported"); | ||
}, | ||
}); | ||
const toEqualFile = (actual, { filename, code }) => { | ||
const pass = actual === code; | ||
return { | ||
pass, | ||
message: pass | ||
? () => { | ||
throw new Error(".toEqualFile does not support negation"); | ||
} | ||
: () => { | ||
const diffString = diff(code, actual, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this uses an imported |
||
expand: false, | ||
}); | ||
return ( | ||
`Expected ${filename} to match transform output.\n` + | ||
`To autogenerate a passing version of this file, delete the file and re-run the tests.\n\n` + | ||
`Diff:\n\n${diffString}` | ||
); | ||
}, | ||
}; | ||
}; | ||
|
||
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({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorta weird to |
||
toEqualFile, | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can check
this.isNot
and throw earlier. doesn't matter in practice I guess