Skip to content

Commit 812c223

Browse files
committed
test: add unit tests for vitest RUN line Windows path normalization
1 parent 6866757 commit 812c223

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

packages/tools/src/__tests__/utils.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,32 @@ Done in 171ms using pnpm v10.16.1
146146
});
147147
});
148148

149+
test('normalize vitest RUN line with Windows absolute path', () => {
150+
const output = ' RUN C:/Users/RUNNER~1/AppData/Local/Temp/vite-plus-test-abc/my-test\n';
151+
expect(replaceUnstableOutput(output)).toBe(' RUN <cwd>\n');
152+
});
153+
154+
test('normalize vitest RUN line with Windows backslash path', () => {
155+
const output = ' RUN C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\vite-plus-test-abc\\my-test\n';
156+
expect(replaceUnstableOutput(output)).toBe(' RUN <cwd>\n');
157+
});
158+
159+
test('normalize vitest RUN line with version and Windows path', () => {
160+
const output = ' RUN v1.0.0 C:/Users/RUNNER~1/AppData/Local/Temp/vite-plus-test-abc/my-test\n';
161+
expect(replaceUnstableOutput(output)).toBe(' RUN v<semver> <cwd>\n');
162+
});
163+
164+
test('preserve vitest RUN line already normalized with <cwd>', () => {
165+
const output = ' RUN <cwd>\n';
166+
expect(replaceUnstableOutput(output)).toBe(' RUN <cwd>\n');
167+
});
168+
169+
test.skipIf(process.platform === 'win32')('normalize vitest RUN line with cwd on Unix', () => {
170+
const cwd = '/tmp/vite-plus-test-abc/my-test';
171+
const output = ` RUN ${cwd}\n`;
172+
expect(replaceUnstableOutput(output, cwd)).toBe(' RUN <cwd>\n');
173+
});
174+
149175
test('replace tsdown output', () => {
150176
const output = `
151177
ℹ tsdown v0.15.1 powered by rolldown v0.15.1

0 commit comments

Comments
 (0)