-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): deprecate
cache.dir
option (#5229)
- Loading branch information
Showing
10 changed files
with
162 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { expect, test } from "vitest"; | ||
|
||
test('', () => { | ||
expect(true).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { describe, expect, test } from 'vitest' | ||
import { resolve } from 'pathe' | ||
import { runVitest } from '../../test-utils' | ||
|
||
const root = resolve(__dirname, '../fixtures/cache') | ||
const project = resolve(__dirname, '../') | ||
|
||
test('default', async () => { | ||
const { vitest, stdout, stderr } = await runVitest({ | ||
root, | ||
include: ['*.test.ts'], | ||
}) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(project, 'node_modules/.vite/vitest/results.json') | ||
expect(cachePath).toMatch(path) | ||
}) | ||
|
||
test('use cache.dir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
cache: { | ||
dir: 'node_modules/.vitest-custom', | ||
}, | ||
}, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toContain('"cache.dir" is deprecated') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vitest-custom/results.json') | ||
expect(cachePath).toMatch(path) | ||
}) | ||
|
||
test('use cacheDir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
}, | ||
[], | ||
'test', | ||
{ cacheDir: 'node_modules/.vite-custom' }, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vite-custom/vitest/results.json') | ||
expect(cachePath).toMatch(path) | ||
}) | ||
|
||
describe('with optimizer enabled', () => { | ||
const deps = { | ||
optimizer: { | ||
web: { | ||
enabled: true, | ||
}, | ||
}, | ||
} | ||
|
||
test('default', async () => { | ||
const { vitest, stdout, stderr } = await runVitest({ | ||
root, | ||
include: ['*.test.ts'], | ||
deps, | ||
}) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(project, 'node_modules/.vite/vitest/results.json') | ||
expect(cachePath).toBe(path) | ||
}) | ||
|
||
test('use cache.dir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
deps, | ||
cache: { | ||
dir: 'node_modules/.vitest-custom', | ||
}, | ||
}, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toContain('"cache.dir" is deprecated') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vitest-custom/results.json') | ||
expect(cachePath).toBe(path) | ||
}) | ||
|
||
test('use cacheDir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
deps, | ||
}, | ||
[], | ||
'test', | ||
{ cacheDir: 'node_modules/.vite-custom' }, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vite-custom/vitest/results.json') | ||
expect(cachePath).toBe(path) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters