1
0
mirror of synced 2026-01-04 00:06:20 -05:00

Clean up jest (#50177)

This commit is contained in:
Peter Bengtsson
2024-04-16 15:38:46 -04:00
committed by GitHub
parent a863eab83f
commit 227e4e2bbf
24 changed files with 55 additions and 3071 deletions

View File

@@ -22,7 +22,7 @@ describe('annotate', () => {
// but in this case its a short and concise example
// that won't change regularly.
// If it fails, study the output and make sure it's correct.
// If it is indeed correct, run `jest --updateSnapshot` to update it.
// If it is indeed correct, run `vitest --updateSnapshot` to update it.
expect(await renderContent(example)).toMatchSnapshot()
})

View File

@@ -67,12 +67,12 @@ vi.setConfig({ testTimeout: 60 * 1000 })
describe('changed-content', () => {
const changedContentFiles = getChangedContentFiles()
// `jest.each` will throw if the array is empty, so we need to add a dummy
// `test.each` will throw if the array is empty, so we need to add a dummy
// when there are no changed files in the environment.
if (!changedContentFiles.length) changedContentFiles.push(EMPTY)
test.each(changedContentFiles)('changed-content: %s', async (file) => {
// Necessary because `jest.each` will throw if the array is empty
// Necessary because `test.each` will throw if the array is empty
if (file === EMPTY) return
const page = pageList.find((p) => {
@@ -87,7 +87,7 @@ describe('changed-content', () => {
if (!res.ok) {
let msg = `This error happened when rendering from: ${file}\n`
msg +=
'To see the full error from jest re-run the test with DEBUG_MIDDLEWARE_TESTS=true set\n'
'To see the full error from vitest re-run the test with DEBUG_MIDDLEWARE_TESTS=true set\n'
msg += `Or, to view it locally start the server (npm run dev) and visit http://localhost:4000${href}`
console.log(msg)
throw new Error(`Rendering ${href} failed with status ${res.statusCode}`)
@@ -99,12 +99,12 @@ describe('changed-content', () => {
describe('deleted-content', () => {
const deletedContentFiles = getDeletedContentFiles()
// `jest.each` will throw if the array is empty, so we need to add a dummy
// `test.each` will throw if the array is empty, so we need to add a dummy
// when there are no deleted files in the environment.
if (!deletedContentFiles.length) deletedContentFiles.push(EMPTY)
test.each(deletedContentFiles)('deleted-content: %s', async (file) => {
// Necessary because `jest.each` will throw if the array is empty
// Necessary because `test.each` will throw if the array is empty
if (file === EMPTY) return
const page = pageList.find((p) => {