From da2431876d644633b5929b01a651b347ac3ba349 Mon Sep 17 00:00:00 2001 From: Stephen Yeung Date: Thu, 6 Sep 2018 09:48:10 -0700 Subject: [PATCH] Tests: Fix cli tests to work with promise handling in qunit callbacks --- test/cli/fixtures/expected/tap-outputs.js | 20 ++++++++++++++++---- test/cli/main.js | 6 ++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/test/cli/fixtures/expected/tap-outputs.js b/test/cli/fixtures/expected/tap-outputs.js index fe469551c..8e3b6f8df 100644 --- a/test/cli/fixtures/expected/tap-outputs.js +++ b/test/cli/fixtures/expected/tap-outputs.js @@ -126,15 +126,21 @@ not ok 2 global failure # fail 2 `, + // in node 8, the stack trace includes 'at . 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 )? + at process._tickCallback (.*) ... 1..1 # pass 0 @@ -143,15 +149,21 @@ not ok 1 global failure # fail 1 `, + // in node 8, the stack trace includes 'at . 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 )? + at process._tickCallback (.*) ... 1..1 # pass 0 diff --git a/test/cli/main.js b/test/cli/main.js index d5de0a4cf..bc6c929a0 100644 --- a/test/cli/main.js +++ b/test/cli/main.js @@ -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 ); } } ) ); @@ -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 ); } } ) ); } );