From ed2c5639d47734db226be2b03d6b6379cb8525ba Mon Sep 17 00:00:00 2001 From: Lars den Bakker Date: Fri, 2 Oct 2020 22:19:09 +0200 Subject: [PATCH] feat(test-runner): improve error message when no browsers are configured --- .changeset/khaki-carpets-tan.md | 6 ++++++ .../test-runner-core/src/runner/TestRunner.ts | 16 ++++++++++++---- packages/test-runner/web-test-runner.config.mjs | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .changeset/khaki-carpets-tan.md diff --git a/.changeset/khaki-carpets-tan.md b/.changeset/khaki-carpets-tan.md new file mode 100644 index 000000000..c42dabbc1 --- /dev/null +++ b/.changeset/khaki-carpets-tan.md @@ -0,0 +1,6 @@ +--- +'@web/test-runner': patch +'@web/test-runner-core': patch +--- + +improve error message when no browsers are configured diff --git a/packages/test-runner-core/src/runner/TestRunner.ts b/packages/test-runner-core/src/runner/TestRunner.ts index 17770da02..aa7aa5dee 100644 --- a/packages/test-runner-core/src/runner/TestRunner.ts +++ b/packages/test-runner-core/src/runner/TestRunner.ts @@ -39,16 +39,24 @@ export class TestRunner extends EventEmitter { 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))); diff --git a/packages/test-runner/web-test-runner.config.mjs b/packages/test-runner/web-test-runner.config.mjs index 5c86f32a0..51cd6f605 100644 --- a/packages/test-runner/web-test-runner.config.mjs +++ b/packages/test-runner/web-test-runner.config.mjs @@ -2,4 +2,5 @@ export default { rootDir: '../../', preserveSymlinks: true, nodeResolve: true, + browsers: [], };