Skip to content

Commit

Permalink
fix: make error more informative
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Mar 22, 2022
1 parent ae7cc44 commit 5ced470
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions samples/basic/test/mul.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { expect, describe, it } from "vitest";

describe("mul", () => {
it.skip("run", () => {});
it("run", () => {});
});
30 changes: 11 additions & 19 deletions src/pure/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class TestRunner {
});
constructor(
private workspacePath: string,
private vitePath: string | undefined
private vitestPath: string | undefined
) {}

async scheduleRun(
Expand All @@ -91,10 +91,12 @@ export class TestRunner {
args.push("-t", testNamePattern);
}

let child;
let error: any;
try {
let child;
if (this.vitePath) {
child = spawn(this.vitePath, args, {
// it will throw when test failed or the testing is failed to run
if (this.vitestPath) {
child = spawn(this.vitestPath, args, {
cwd: this.workspacePath,
stdio: ["ignore", "pipe", "pipe"],
});
Expand All @@ -109,24 +111,14 @@ export class TestRunner {
log(line + "\r\n");
}
} catch (e) {
console.error(e);
error = e;
}

if (!existsSync(path)) {
return {
numFailedTests: 0,
numFailedTestSuites: 0,
numPassedTests: 0,
numPassedTestSuites: 0,
numPendingTests: 0,
numTodoTests: 0,
numPendingTestSuites: 0,
numTotalTests: 0,
numTotalTestSuites: 0,
startTime: 0,
success: false,
testResults: [],
};
console.error("scheduleRun error", error.toString());
console.error(error.stack);
console.log("vitestPah", this.vitestPath, args, this.workspacePath);
throw error;
}

const file = await readFile(path, "utf-8");
Expand Down
2 changes: 1 addition & 1 deletion src/runHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async function runTest(
run.errored(
testCase,
new vscode.TestMessage(
"Testing is not started correctly. Please check your configuration."
"Unexpected condition. Please report the bug to https://github.com/zxch3n/vitest-explorer/issues"
)
);
});
Expand Down

0 comments on commit 5ced470

Please sign in to comment.