Skip to content

Commit

Permalink
Tests: Fix cli tests to work with promise handling in qunit callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
step2yeung committed Sep 19, 2018
1 parent 6711d27 commit da24318
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 16 additions & 4 deletions test/cli/fixtures/expected/tap-outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,21 @@ not ok 2 global failure
# fail 2
`,

// in node 8, the stack trace includes 'at <anonymous>. But not in node 6 or 10.
"qunit no-tests":
`TAP version 13
not ok 1 global failure
---
message: "No tests were run."
severity: failed
actual: null
actual: {}
expected: undefined
stack: undefined:undefined
stack: Error: No tests were run.
at done (.*)
at advanceTestQueue (.*)
at Object.advance (.*)
at unblockAndAdvanceQueue (.*)(\n at <anonymous>)?
at process._tickCallback (.*)
...
1..1
# pass 0
Expand All @@ -143,15 +149,21 @@ not ok 1 global failure
# fail 1
`,

// in node 8, the stack trace includes 'at <anonymous>. But not in node 6 or 10.
"qunit qunit --filter 'no matches' test":
`TAP version 13
not ok 1 global failure
---
message: "No tests matched the filter "no matches"."
severity: failed
actual: null
actual: {}
expected: undefined
stack: undefined:undefined
stack: Error: No tests matched the filter "no matches".
at done (.*)
at advanceTestQueue (.*)
at Object.advance (.*)
at unblockAndAdvanceQueue (.*)(\n at <anonymous>)?
at process._tickCallback (.*)
...
1..1
# pass 0
Expand Down
6 changes: 4 additions & 2 deletions test/cli/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ QUnit.module( "CLI Main", function() {
} catch ( e ) {
assert.equal( e.code, 1 );
assert.equal( e.stderr, "" );
assert.equal( e.stdout, expectedOutput[ command ] );
const re = new RegExp( expectedOutput[ command ] );
assert.equal( re.test( e.stdout ), true );
}
} ) );

Expand Down Expand Up @@ -153,7 +154,8 @@ QUnit.module( "CLI Main", function() {
} catch ( e ) {
assert.equal( e.code, 1 );
assert.equal( e.stderr, "" );
assert.equal( e.stdout, expectedOutput[ command ] );
const re = new RegExp( expectedOutput[ command ] );
assert.equal( re.test( e.stdout ), true );
}
} ) );
} );
Expand Down

0 comments on commit da24318

Please sign in to comment.