| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,8 +45,9 @@ export class ResultsCache { | |||
| 45 | 45 | ||
| 46 | 46 | const resultsCache = await fs.promises.readFile(this.cachePath, 'utf8') | |
| 47 | 47 | const { results, version } = JSON.parse(resultsCache || '[]') | |
| 48 | + const [major, minor] = version.split('.') | ||
| 48 | 49 | // handling changed in 0.30.0 | |
| 49 | - if (Number(version.split('.')[1]) >= 30) { | ||
| 50 | + if (major > 0 || Number(minor) >= 30) { | ||
| 50 | 51 | this.cache = new Map(results) | |
| 51 | 52 | this.version = version | |
| 52 | 53 | results.forEach(([spec]: [string]) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + import { expect, test } from "vitest"; | ||
| 2 | + | ||
| 3 | + test('', () => { | ||
| 4 | + expect(true).toBe(true) | ||
| 5 | + }) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 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: { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments