Skip to content

Commit

Permalink
fix(test): remove broken monitor action for Cucumber
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devoto13 committed May 21, 2019
1 parent 27a646e commit cc755c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
5 changes: 2 additions & 3 deletions test/e2e/error.feature
Expand Up @@ -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'];
Expand All @@ -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 }
Expand Down
17 changes: 3 additions & 14 deletions test/e2e/step_definitions/core_steps.js
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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/
Expand Down

0 comments on commit cc755c5

Please sign in to comment.