From cc755c5460ef87d7b85a999874d0abed43b5709e Mon Sep 17 00:00:00 2001 From: Yaroslav Admin Date: Tue, 21 May 2019 21:28:43 +0200 Subject: [PATCH] fix(test): remove broken monitor action for Cucumber The issue is that it resulted in the following sequence of actions: - run karma start - run karma run - and then instantly kill karma start command This resulted in flaky tests because preliminary killing resulted in incomplete output. In fact test was unnecessary complicated as it was enough to use runOut, which asserts output of the karma run command. --- test/e2e/error.feature | 5 ++--- test/e2e/step_definitions/core_steps.js | 17 +++-------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/test/e2e/error.feature b/test/e2e/error.feature index 9d0f3d98d..7bda9a772 100644 --- a/test/e2e/error.feature +++ b/test/e2e/error.feature @@ -18,7 +18,7 @@ Feature: Error Display """ SyntaxError: Unexpected token } """ - Scenario: Single-run Syntax Error in a test file + Scenario: Not single-run Syntax Error in a test file Given a configuration with: """ files = ['error/test.js', 'error/under-test.js']; @@ -29,8 +29,7 @@ Feature: Error Display ]; singleRun = false; """ - When I monitor Karma - And I stop when the log contains 'SyntaxError' + When I runOut Karma Then it fails with like: """ SyntaxError: Unexpected token } diff --git a/test/e2e/step_definitions/core_steps.js b/test/e2e/step_definitions/core_steps.js index 3d7581424..02e1d8d33 100644 --- a/test/e2e/step_definitions/core_steps.js +++ b/test/e2e/step_definitions/core_steps.js @@ -64,7 +64,7 @@ cucumber.defineSupportCode((a) => { } const runOut = command === 'runOut' - if (command === 'run' || command === 'runOut' || command === 'monitor') { + if (command === 'run' || command === 'runOut') { this.child = spawn('' + runtimePath, ['start', '--log-level', 'warn', configFile]) const done = () => { cleansingNeeded = true @@ -87,18 +87,16 @@ cucumber.defineSupportCode((a) => { setTimeout(() => { exec(cmd, { cwd: baseDir - }, (error, stdout) => { + }, (error, stdout, stderr) => { if (error) { this.lastRun.error = error } if (runOut) { this.lastRun.stdout = stdout + this.lastRun.stderr = stderr } done() }) - if (command === 'monitor') { - done() - } }, 1000) }) } else { @@ -180,15 +178,6 @@ cucumber.defineSupportCode((a) => { execKarma.apply(this, [command, undefined, proxyPort, proxyPath, callback]) }) - When('I stop when the log contains {string}', function (message, callback) { - setInterval(() => { - if (this.lastRun.stdout.includes(message)) { - this.child && this.child.kill() - callback() - } - }, 100) - }) - defineParameterType({ name: 'exact', regexp: /no\sdebug|like/