Skip to content

Commit

Permalink
test: add test for vitest-dev#2943
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Mar 7, 2023
1 parent a1954cc commit 3331365
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/watch/test/stdout.test.ts
@@ -0,0 +1,32 @@
import { readFileSync, writeFileSync } from 'fs'
import { afterEach, expect, test } from 'vitest'

import { startWatchMode, waitFor } from './utils'

const testFile = 'fixtures/math.test.ts'
const testFileContent = readFileSync(testFile, 'utf-8')

afterEach(() => {
writeFileSync(testFile, testFileContent, 'utf8')
})

test('console.log is visible on test re-run', async () => {
const vitest = await startWatchMode()
const testCase = `
test('test with logging', () => {
console.log('First')
console.log('Second')
console.log('Third')
expect(true).toBe(true)
})
`

writeFileSync(testFile, `${testFileContent}${testCase}`, 'utf8')

await waitFor(() => {
expect(vitest.getOutput()).toMatch('stdout | math.test.ts > test with logging')
expect(vitest.getOutput()).toMatch('First')
expect(vitest.getOutput()).toMatch('Second')
expect(vitest.getOutput()).toMatch('Third')
})
})

0 comments on commit 3331365

Please sign in to comment.