-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Trent Willis
committed
Mar 22, 2017
1 parent
1847361
commit e0201fc
Showing
15 changed files
with
295 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ node_js: | |
- "7" | ||
env: | ||
- NPM_SCRIPT=test | ||
- NPM_SCRIPT=test:cli | ||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
QUnit.module( "Double", function() { | ||
QUnit.test( "has a test", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
|
||
QUnit.test( "has another test", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Expected outputs from the TapReporter for the commands run in CLI tests | ||
module.exports = { | ||
"qunit": | ||
`TAP version 13 | ||
ok 1 First > 1 | ||
ok 2 Second > 1 | ||
1..2 | ||
# pass 2 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0`, | ||
|
||
"qunit 'glob/**/*-test.js'": | ||
`TAP version 13 | ||
ok 1 A-Test > derp | ||
ok 2 Nested-Test > herp | ||
1..2 | ||
# pass 2 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0`, | ||
|
||
"qunit single.js": | ||
`TAP version 13 | ||
ok 1 Single > has a test | ||
1..1 | ||
# pass 1 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0`, | ||
|
||
"qunit single.js double.js": | ||
`TAP version 13 | ||
ok 1 Double > has a test | ||
ok 2 Double > has another test | ||
ok 3 Single > has a test | ||
1..3 | ||
# pass 3 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0`, | ||
|
||
"qunit test": | ||
`TAP version 13 | ||
ok 1 First > 1 | ||
ok 2 Second > 1 | ||
1..2 | ||
# pass 2 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0`, | ||
|
||
"qunit test single.js 'glob/**/*-test.js'": | ||
`TAP version 13 | ||
ok 1 A-Test > derp | ||
ok 2 Nested-Test > herp | ||
ok 3 Single > has a test | ||
ok 4 First > 1 | ||
ok 5 Second > 1 | ||
1..5 | ||
# pass 5 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0` | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
QUnit.module( "Failure", function() { | ||
QUnit.test( "bad", function( assert ) { | ||
assert.ok( false ); | ||
} ); | ||
|
||
QUnit.test( "bad again", function( assert ) { | ||
assert.ok( false ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.module( "A-Test", function() { | ||
QUnit.test( "derp", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.module( "Not-A", function() { | ||
QUnit.test( "1", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.module( "Nested-Test", function() { | ||
QUnit.test( "herp", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.module( "Single", function() { | ||
QUnit.test( "has a test", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.module( "First", function() { | ||
QUnit.test( "1", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.module( "Second", function() { | ||
QUnit.test( "1", function( assert ) { | ||
assert.ok( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
"use strict"; | ||
|
||
const path = require( "path" ); | ||
const exec = require( "execa" ).shell; | ||
const co = require( "co" ); | ||
|
||
const expectedOutput = require( "./fixtures/expected/tap-outputs" ); | ||
|
||
// Executes the provided command from within the fixtures directory | ||
function execute( command ) { | ||
const cwd = process.cwd(); | ||
process.chdir( path.join( __dirname, "fixtures" ) ); | ||
|
||
const execution = exec( command ); | ||
|
||
process.chdir( cwd ); | ||
|
||
return execution; | ||
} | ||
|
||
QUnit.module( "CLI Main", function() { | ||
QUnit.test( "defaults to running tests in 'test' directory", co.wrap( function* ( assert ) { | ||
const command = "qunit"; | ||
const execution = yield execute( command ); | ||
|
||
assert.equal( execution.code, 0 ); | ||
assert.equal( execution.stderr, "" ); | ||
assert.equal( execution.stdout, expectedOutput[ command ] ); | ||
} ) ); | ||
|
||
QUnit.test( "errors if no test files are found to run", co.wrap( function* ( assert ) { | ||
try { | ||
yield execute( "qunit does-not-exist.js" ); | ||
} catch ( e ) { | ||
assert.equal( e.stderr.indexOf( "No files were found matching" ), 0 ); | ||
} | ||
} ) ); | ||
|
||
QUnit.test( "accepts globs for test files to run", co.wrap( function* ( assert ) { | ||
const command = "qunit 'glob/**/*-test.js'"; | ||
const execution = yield execute( command ); | ||
|
||
assert.equal( execution.code, 0 ); | ||
assert.equal( execution.stderr, "" ); | ||
assert.equal( execution.stdout, expectedOutput[ command ] ); | ||
} ) ); | ||
|
||
QUnit.test( "runs a single JS file", co.wrap( function* ( assert ) { | ||
const command = "qunit single.js"; | ||
const execution = yield execute( command ); | ||
|
||
assert.equal( execution.code, 0 ); | ||
assert.equal( execution.stderr, "" ); | ||
assert.equal( execution.stdout, expectedOutput[ command ] ); | ||
} ) ); | ||
|
||
QUnit.test( "runs multiple JS files", co.wrap( function* ( assert ) { | ||
const command = "qunit single.js double.js"; | ||
const execution = yield execute( command ); | ||
|
||
assert.equal( execution.code, 0 ); | ||
assert.equal( execution.stderr, "" ); | ||
assert.equal( execution.stdout, expectedOutput[ command ] ); | ||
} ) ); | ||
|
||
QUnit.test( "runs all JS files in a directory matching an arg", co.wrap( function* ( assert ) { | ||
const command = "qunit test"; | ||
const execution = yield execute( command ); | ||
|
||
assert.equal( execution.code, 0 ); | ||
assert.equal( execution.stderr, "" ); | ||
assert.equal( execution.stdout, expectedOutput[ command ] ); | ||
} ) ); | ||
|
||
QUnit.test( "runs multiple types of file paths", co.wrap( function* ( assert ) { | ||
const command = "qunit test single.js 'glob/**/*-test.js'"; | ||
const execution = yield execute( command ); | ||
|
||
assert.equal( execution.code, 0 ); | ||
assert.equal( execution.stderr, "" ); | ||
assert.equal( execution.stdout, expectedOutput[ command ] ); | ||
} ) ); | ||
|
||
QUnit.test( "exit code is 1 when failing tests are present", co.wrap( function* ( assert ) { | ||
try { | ||
yield execute( "qunit fail/*.js" ); | ||
} catch ( e ) { | ||
assert.equal( e.code, 1 ); | ||
} | ||
} ) ); | ||
} ); |
Oops, something went wrong.