Skip to content

Commit

Permalink
tests: awaiting toMatchFileSnapshot and .rejects statements in vi…
Browse files Browse the repository at this point in the history
…test files (#2984)

Co-authored-by: David Turissini <davidturissini@Melissas-Air.home>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent a6dd6bf commit a365896
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('deny-route-group-config throws', () => {
const config = await setupConfig(folder)
const folderRoot = makeFolderDir(folder)

expect(() => generator(config, folderRoot)).rejects.toThrowError(
await expect(() => generator(config, folderRoot)).rejects.toThrowError(
expectedError,
)
},
Expand Down
14 changes: 9 additions & 5 deletions packages/router-generator/tests/generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ async function postprocess(folderName: string) {
const routeFiles = await readDir(folderName, 'routes', '(test)')
routeFiles
.filter((r) => r.endsWith('.tsx'))
.forEach((routeFile) => {
expect(fooText).toMatchFileSnapshot(
.forEach(async (routeFile) => {
await expect(fooText).toMatchFileSnapshot(
join('generator', folderName, 'snapshot', routeFile),
)
})
Expand All @@ -191,7 +191,9 @@ async function postprocess(folderName: string) {
await traverseDirectory(startDir, async (filePath) => {
const relativePath = relative(startDir, filePath)
if (filePath.endsWith('.tsx')) {
expect(await fs.readFile(filePath, 'utf-8')).toMatchFileSnapshot(
await expect(
await fs.readFile(filePath, 'utf-8'),
).toMatchFileSnapshot(
join('generator', folderName, 'snapshot', relativePath),
)
}
Expand Down Expand Up @@ -222,13 +224,15 @@ describe('generator works', async () => {
await preprocess(folderName)
const error = shouldThrow(folderName)
if (error) {
expect(() => generator(config, folderRoot)).rejects.toThrowError(error)
await expect(() => generator(config, folderRoot)).rejects.toThrowError(
error,
)
} else {
await generator(config, folderRoot)

const generatedRouteTree = await getRouteTreeFileText(config)

expect(generatedRouteTree).toMatchFileSnapshot(
await expect(generatedRouteTree).toMatchFileSnapshot(
join(
'generator',
folderName,
Expand Down

0 comments on commit a365896

Please sign in to comment.