Skip to content

Commit

Permalink
Tests: Confirm that NODE_OPTIONS --enable-source-maps works
Browse files Browse the repository at this point in the history
Ref #590.
  • Loading branch information
Krinkle committed Aug 30, 2020
1 parent c3d8b71 commit bde6dd4
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
37 changes: 37 additions & 0 deletions test/cli/fixtures/expected/tap-outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,43 @@ not ok 1 global failure
# skip 0
# todo 0
# fail 1
`,

"qunit sourcemap/source.js":
`TAP version 13
ok 1 Example > good
not ok 2 Example > bad
---
message: "failed"
severity: failed
actual: false
expected: true
stack: at .* \\(.*source.js:7:14\\)
...
1..2
# pass 1
# skip 0
# todo 0
# fail 1
`,

"NODE_OPTIONS='--enable-source-maps' qunit sourcemap/source.min.js":
`TAP version 13
ok 1 Example > good
not ok 2 Example > bad
---
message: "failed"
severity: failed
actual: false
expected: true
stack: at .* \\(.*source.min.js:1:.*\\)
-> .*source.js:7:10
...
1..2
# pass 1
# skip 0
# todo 0
# fail 1
`,

"qunit timeout":
Expand Down
9 changes: 9 additions & 0 deletions test/cli/fixtures/sourcemap/source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
QUnit.module( "Example", function() {
QUnit.test( "good", function( assert ) {
assert.true( true );
} );

QUnit.test( "bad", function( assert ) {
assert.true( false );
} );
} );
2 changes: 2 additions & 0 deletions test/cli/fixtures/sourcemap/source.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/cli/fixtures/sourcemap/source.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/cli/helpers/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function execute( command, execaOptions ) {
const cwd = process.cwd();
process.chdir( path.join( __dirname, "..", "fixtures" ) );

command = command.replace( /^qunit\b/, "../../../bin/qunit.js" );
command = command.replace( /(^| )qunit\b/, "$1../../../bin/qunit.js" );
const execution = exec( command, execaOptions );

process.chdir( cwd );
Expand Down
31 changes: 31 additions & 0 deletions test/cli/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,37 @@ QUnit.module( "CLI Main", function() {
}
} );

// https://nodejs.org/dist/v12.12.0/docs/api/cli.html#cli_enable_source_maps
if ( semver.gte( process.versions.node, "14.0.0" ) ) {

QUnit.test( "normal trace with native source map", async function( assert ) {
const command = "qunit sourcemap/source.js";
try {
await execute( command );
} catch ( e ) {
assert.equal( e.code, 1 );
assert.equal( e.stderr, "" );
const re = new RegExp( expectedOutput[ command ] );
assert.equal( re.test( e.stdout ), true );
}
} );

QUnit.test( "mapped trace with native source map", async function( assert ) {
const command = "NODE_OPTIONS='--enable-source-maps' qunit sourcemap/source.min.js";
try {
await execute( command );
} catch ( e ) {
assert.equal( e.code, 1 );
assert.equal( e.stderr, "" );
const re = new RegExp( expectedOutput[ command ] );
assert.equal( re.test( e.stdout ), true );
if ( !re.test( e.stdout ) ) {
assert.equal( e.stdout, expectedOutput[ command ] );
}
}
} );
}

QUnit.test( "timeouts correctly recover", async function( assert ) {
const command = "qunit timeout";
try {
Expand Down

0 comments on commit bde6dd4

Please sign in to comment.