Skip to content

Commit

Permalink
Run js tests cleanup using onTestFinished
Browse files Browse the repository at this point in the history
  • Loading branch information
dobrac committed Dec 3, 2024
1 parent 84e1307 commit 666b3d4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/js-sdk/tests/sandbox/files/watch.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'vitest'
import { expect, onTestFinished } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { FilesystemEventType, NotFoundError, SandboxError } from '../../../src'
Expand Down Expand Up @@ -38,8 +38,9 @@ sandboxTest('watch recursive directory changes', async ({ sandbox }) => {
const content = 'This file will be watched.'
const newContent = 'This file has been modified.'

await sandbox.files.remove(dirname)
await sandbox.files.makeDir(`${dirname}/${nestedDirname}`)
onTestFinished(() => sandbox.files.remove(dirname))

await sandbox.files.write(`${dirname}/${nestedDirname}/${filename}`, content)

let trigger: () => void
Expand Down Expand Up @@ -70,8 +71,8 @@ sandboxTest('watch recursive directory after nested folder addition', async ({ s
const filename = 'test_watch.txt'
const content = 'This file will be watched.'

await sandbox.files.remove(dirname)
await sandbox.files.makeDir(dirname)
onTestFinished(() => sandbox.files.remove(dirname))

let triggerFile: () => void
let triggerFolder: () => void
Expand Down

0 comments on commit 666b3d4

Please sign in to comment.