Skip to content

Commit

Permalink
feat(test-runner): improve error message when no browsers are configured
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsDenBakker committed Oct 2, 2020
1 parent fcc2e28 commit 72ffcde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/khaki-carpets-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@web/test-runner': patch
'@web/test-runner-core': patch
---

improve error message when no browsers are configured
16 changes: 12 additions & 4 deletions packages/test-runner-core/src/runner/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,24 @@ export class TestRunner extends EventEmitter<EventMap> {

constructor(config: TestRunnerCoreConfig, groupConfigs: TestRunnerGroupConfig[] = []) {
super();
if (!config.manual && (!config.browsers || config.browsers.length === 0)) {
throw new Error('No browsers are configured to run tests');
}

if (config.manual && config.watch) {
throw new Error('Cannot combine the manual and watch options.');
}

if (config.open && !config.manual) {
throw new Error('The open option requires the manual option to be set.');
}

const { sessionGroups, testFiles, testSessions, browsers } = createTestSessions(
config,
groupConfigs,
);
this.config = config;

if (this.config.manual && this.config.watch) {
throw new Error('Cannot combine the manual and watch options.');
}

this.testFiles = testFiles;
this.browsers = browsers;
this.browserNames = Array.from(new Set(this.browsers.map(b => b.name)));
Expand Down
1 change: 1 addition & 0 deletions packages/test-runner/web-test-runner.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export default {
rootDir: '../../',
preserveSymlinks: true,
nodeResolve: true,
browsers: [],
};

0 comments on commit 72ffcde

Please sign in to comment.