Skip to content

Commit 212e77a

Browse files
committed
fix: files not found causing tests to not be reported
Fixes #2
1 parent 6e4b5f5 commit 212e77a

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

src/runner-worker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ async function doWork(prefix: string, queue: ITestRunFile[]) {
108108
}
109109

110110
await new Promise<void>((resolve) => {
111+
server.output(`${prefix}starting ${ansiColors.underline(next.path)}`);
112+
111113
const args = ["--require", join(__dirname, "runner-loader.js")];
112114
for (const include of next.include || []) {
113115
args.push("--test-name-pattern", `^${escapeRegex(include)}$`);
114116
}
115117
args.push(next.path);
116-
server.output(`${prefix}starting ${ansiColors.underline(next.path)}`);
117118

118119
const stderr: Buffer[] = [];
119120
const cp = spawn(process.argv0, args, {

src/source-map-store.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { promises as fs } from "fs";
22
import * as vscode from "vscode";
3-
import { IMappingAccessor, parseSourceMap } from "./source-map";
3+
import { identityMapping, IMappingAccessor, parseSourceMap } from "./source-map";
44

55
export interface ISourceMapMaintainer {
66
value: Promise<IMappingAccessor> | undefined;
@@ -35,7 +35,10 @@ export class SourceMapStore {
3535
},
3636
async refresh(contents) {
3737
const contentsProm = fs.readFile(uri.fsPath, "utf8") || Promise.resolve(contents);
38-
return (rec.accessor = contentsProm.then((c) => parseSourceMap(uri, c)));
38+
return (rec.accessor = contentsProm.then(
39+
(c) => parseSourceMap(uri, c),
40+
() => identityMapping(uri)
41+
));
3942
},
4043
dispose() {
4144
if (--rec.rc === 0) {

src/source-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface IMappingAccessor {
1414
originalPositionFor(line: number, col: number): vscode.Location;
1515
}
1616

17-
const identityMapping = (file: vscode.Uri): IMappingAccessor => ({
17+
export const identityMapping = (file: vscode.Uri): IMappingAccessor => ({
1818
originalPositionFor(line, col) {
1919
// VS Code positions are base 0, adjust the line
2020
return new vscode.Location(file, new vscode.Position(line - 1, col));

testCases/simple/workspace/withADashTheOtherWay-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ const { test } = require("node:test");
22
const { strictEqual } = require("node:assert");
33

44
test("addition", () => {
5-
strictEqual(1 + 1, 2);
5+
require('node:fs').readFileSync('does not exist');
66
});

0 commit comments

Comments
 (0)