Skip to content

Commit a1a528c

Browse files
committed
test: Ensures database cleanup on test completion
Adds a check to ensure the test database file exists before attempting to delete it. This prevents errors if the file was not created in the first place, leading to a more robust and reliable test suite.
1 parent 79e7521 commit a1a528c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

test/basic.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ describe('ssr', async () => {
1010
})
1111

1212
afterEach(async () => {
13-
// remove the test db file
14-
await fs.promises.unlink(path.join(process.cwd(), '_basic-test'))
13+
const dbPath = path.join(process.cwd(), '_basic-test')
14+
if (fs.existsSync(dbPath)) {
15+
await fs.promises.unlink(dbPath)
16+
}
1517
})
1618

1719
it('renders the index page', async () => {

0 commit comments

Comments
 (0)