Skip to content

Commit 8e20d9d

Browse files
test: support context checks on Windows
1 parent 9be63c2 commit 8e20d9d

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎packages/context/tests/lint.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ registerHooks({
9292
process.execPath,
9393
[
9494
'--import',
95-
hookFile,
95+
pathToFileURL(hookFile).href,
9696
'--input-type=module',
9797
'--eval',
9898
`const { listDiagnostics } = await import(${JSON.stringify(moduleUrl)});
@@ -169,7 +169,7 @@ test('captures a deterministic file snapshot with complete inputs and fail statu
169169
{
170170
cwd: workspaceRoot,
171171
fix: false,
172-
overrideConfigFile: expect.stringMatching(/\/rslintConfig\.js$/u),
172+
overrideConfigFile: expect.stringMatching(/[\\/]rslintConfig\.js$/u),
173173
},
174174
]);
175175
expect(mocks.lintFilesCalls).toEqual([['.']]);

‎packages/context/tests/rsdoctor.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ registerHooks({
102102
process.execPath,
103103
[
104104
'--import',
105-
hookFile,
105+
pathToFileURL(hookFile).href,
106106
'--input-type=module',
107107
'--eval',
108108
`const { listRsdoctorToolNames } = await import(${JSON.stringify(moduleUrl)});

‎packages/context/tests/testRun.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,12 @@ test('rejects malformed execution selectors before invoking Rstest', async () =>
607607
test('truncates aggregate execution files deterministically', async () => {
608608
await withTempWorkspace(async (workspaceRoot) => {
609609
const coverage: Record<string, unknown> = {};
610+
const sourceDirectory = path.join(workspaceRoot, 'src');
611+
await mkdir(sourceDirectory, { recursive: true });
612+
const writes: Array<Promise<void>> = [];
610613
for (let index = 1000; index >= 0; index -= 1) {
611-
const sourcePath = path.join(workspaceRoot, 'src', `${index.toString().padStart(4, '0')}.ts`);
612-
await mkdir(path.dirname(sourcePath), { recursive: true });
613-
await writeFile(sourcePath, 'export {};');
614+
const sourcePath = path.join(sourceDirectory, `${index.toString().padStart(4, '0')}.ts`);
615+
writes.push(writeFile(sourcePath, 'export {};'));
614616
coverage[sourcePath] = {
615617
path: sourcePath,
616618
statementMap: {},
@@ -621,6 +623,7 @@ test('truncates aggregate execution files deterministically', async () => {
621623
b: {},
622624
};
623625
}
626+
await Promise.all(writes);
624627
const calls: unknown[] = [];
625628
const capture = await captureTestSnapshot(
626629
workspaceRoot,

‎packages/rstack/tests/context/config.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
22
import os from 'node:os';
33
import path from 'node:path';
4+
import { pathToFileURL } from 'node:url';
45
import { expect, test } from 'rstack/test';
56
import { resolveContextCapture } from '@rstackjs/context';
67
import { loadRstackConfig } from '../../src/config.ts';
@@ -30,11 +31,11 @@ test('resolves context capture with explicit opt-out precedence', () => {
3031
});
3132

3233
test('loads context config separately from app and library configs', async () => {
33-
const configModulePath = path.join(import.meta.dirname, '../../src/config.ts');
34+
const configModuleUrl = pathToFileURL(path.join(import.meta.dirname, '../../src/config.ts')).href;
3435

3536
await withTempConfig(
3637
[
37-
`import { define } from ${JSON.stringify(configModulePath)};`,
38+
`import { define } from ${JSON.stringify(configModuleUrl)};`,
3839
"define.app({ root: 'app-root' });",
3940
"define.lib({ lib: ['src/index.ts'] });",
4041
"define.context({ capture: 'deep', enabled: true, variant: 'firefox_v3' });",

‎packages/rstack/tests/context/mcp.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ registerHooks({
803803
cwd: workspaceRoot,
804804
env: {
805805
...getDefaultEnvironment(),
806-
NODE_OPTIONS: `--import=${hookFile}`,
806+
NODE_OPTIONS: `--import=${pathToFileURL(hookFile).href}`,
807807
RSTACK_RSDOCTOR_LOADED_MARKER: markerFile,
808808
},
809809
stderr: 'pipe',
@@ -852,15 +852,15 @@ test('returns a contained report resource link only for an existing report', asy
852852
report: {
853853
kind: 'html',
854854
path: 'artifacts/report-rsdoctor.html',
855-
uri: `file://${reportPath}`,
855+
uri: pathToFileURL(reportPath).toString(),
856856
},
857857
});
858858
expect(result.content).toEqual(
859859
expect.arrayContaining([
860860
expect.objectContaining({
861861
type: 'resource_link',
862862
name: 'Rsdoctor HTML report',
863-
uri: `file://${reportPath}`,
863+
uri: pathToFileURL(reportPath).toString(),
864864
}),
865865
]),
866866
);

0 commit comments

Comments
 (0)