Skip to content

Commit 3413518

Browse files
authored
fix(vitest): correctly filter changed files when Vitest workspace is used (#4693)
1 parent 4fb7482 commit 3413518

22 files changed

Lines changed: 107 additions & 36 deletions

packages/vitest/src/node/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export class Vitest {
378378
return
379379
const dependencies = [...transformed.deps || [], ...transformed.dynamicDeps || []]
380380
await Promise.all(dependencies.map(async (dep) => {
381-
const path = await this.server.pluginContainer.resolveId(dep, filepath, { ssr: true })
381+
const path = await project.server.pluginContainer.resolveId(dep, filepath, { ssr: true })
382382
const fsPath = path && !path.external && path.id.split('?')[0]
383383
if (fsPath && !fsPath.includes('node_modules') && !deps.has(fsPath) && existsSync(fsPath)) {
384384
deps.add(fsPath)

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/related/tests/not-related.test.ts renamed to test/changed/fixtures/related/not-related.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, test } from 'vitest'
2-
import { B } from '../src/sourceB'
2+
import { B } from './src/sourceB'
33

44
test('shouldn\'t run', () => {
55
expect(B).toBe('B')

test/related/tests/related.test.ts renamed to test/changed/fixtures/related/related.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { access } from 'node:fs'
22
import { sep } from 'pathe'
33
import { expect, test } from 'vitest'
4-
import { A } from '../src/sourceA'
4+
import { A } from './src/sourceA'
55

66
test('A equals A', () => {
77
expect(A).toBe('A')
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function getLetter() {
2+
return 'c';
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { describe, expect, it } from 'vitest';
2+
import getLetter from './index';
3+
describe('getLetter', () => {
4+
const result = getLetter();
5+
it('should return c', () => {
6+
expect(result).toBe('c');
7+
});
8+
});

0 commit comments

Comments
 (0)