|
| 1 | +import { readFileSync } from 'node:fs' |
1 | 2 | import { resolve } from 'pathe'
|
2 | 3 | import { describe, expect, test } from 'vitest'
|
3 | 4 | import { runVitest } from '../../test-utils'
|
@@ -57,6 +58,31 @@ test('use cacheDir', async () => {
|
57 | 58 | expect(cachePath).toMatch(path)
|
58 | 59 | })
|
59 | 60 |
|
| 61 | +test('preserves previous test results', async () => { |
| 62 | + const firstRun = await runVitest({ |
| 63 | + root, |
| 64 | + include: ['basic.test.ts'], |
| 65 | + }) |
| 66 | + |
| 67 | + expect(firstRun.stdout).toContain('✓ basic.test.ts >') |
| 68 | + expect(firstRun.stderr).toBe('') |
| 69 | + |
| 70 | + const cachePath = firstRun.ctx!.cache.results.getCachePath() |
| 71 | + const firstRunCacheContent = readFileSync(cachePath!, 'utf-8') |
| 72 | + expect(firstRunCacheContent).toContain('basic.test.ts') |
| 73 | + |
| 74 | + const secondRun = await runVitest({ |
| 75 | + root, |
| 76 | + include: ['second.test.ts'], |
| 77 | + }) |
| 78 | + expect(secondRun.stdout).toContain('✓ second.test.ts >') |
| 79 | + expect(secondRun.stderr).toBe('') |
| 80 | + |
| 81 | + const secondRunCacheContent = readFileSync(cachePath!, 'utf-8') |
| 82 | + expect(secondRunCacheContent).toContain('basic.test.ts') |
| 83 | + expect(secondRunCacheContent).toContain('second.test.ts') |
| 84 | +}) |
| 85 | + |
60 | 86 | describe('with optimizer enabled', () => {
|
61 | 87 | const deps = {
|
62 | 88 | optimizer: {
|
|
0 commit comments