Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon Test: Clarify message when vitest detects missing deps #29763

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code/addons/test/src/node/test-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ export class TestManager {
this.coverage = payload.config.coverage;
await this.restartVitest({ watchMode: this.watchMode, coverage: this.coverage });
} catch (e) {
const isV8 = e.message?.includes('@vitest/coverage-v8');
const isIstanbul = e.message?.includes('@vitest/coverage-istanbul');

if (e.message?.includes('Error: Failed to load url') && (isIstanbul || isV8)) {
const coveragePackage = isIstanbul ? 'coverage-istanbul' : 'coverage-v8';
e.message = `Please install the @vitest/${coveragePackage} package to run with coverage`;
}
this.reportFatalError('Failed to change coverage mode', e);
}
}
Expand Down
8 changes: 8 additions & 0 deletions code/addons/test/src/node/vitest-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ export class VitestManager {
try {
await this.vitest.init();
} catch (e) {
const isV8 = e.message?.includes('@vitest/coverage-v8');
const isIstanbul = e.message?.includes('@vitest/coverage-istanbul');

if (e.message?.includes('Error: Failed to load url') && (isIstanbul || isV8)) {
const coveragePackage = isIstanbul ? 'coverage-istanbul' : 'coverage-v8';
e.message = `Please install the @vitest/${coveragePackage} package to run with coverage`;
}

this.testManager.reportFatalError('Failed to init Vitest', e);
}

Expand Down