forked from vitest-dev/vitest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stdout.test.ts
32 lines (26 loc) · 907 Bytes
/
stdout.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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')
})
})