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
Showing
2 changed files
with
68 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var test = require('../..').test | ||
|
||
test('root test without {only: true}', function (t) { | ||
t.pass('test will not run without --only') | ||
t.end() | ||
}) | ||
|
||
test('root test with {only: true}', {only: true}, function (t) { | ||
t.pass('test will log an error when run without --only') | ||
t.end() | ||
}) | ||
|
||
test('group', function (group) { | ||
group.test('subtest without {only: true}', function (t) { | ||
t.pass('subtest will not run without --only') | ||
t.end() | ||
}) | ||
|
||
group.test('subtest with {only: true}', {only: true}, function (t) { | ||
t.pass('test will log an error when run without --only') | ||
t.end() | ||
}) | ||
|
||
group.end() | ||
}) |
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,43 @@ | ||
var t = require('../') | ||
var execFile = require('child_process').execFile | ||
var node = process.execPath | ||
var run = require.resolve('../bin/run.js') | ||
|
||
t.test('--only flag', function (t) { | ||
var file = require.resolve('./fixtures/only.js') | ||
var args = [ | ||
run, | ||
'--only', | ||
file | ||
] | ||
|
||
execFile(node, args, function (err, stdout, stderr) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
t.equal(stderr, '') | ||
|
||
t.match(stdout, /^ok 1 - .*[\\\/]only.js/m) | ||
t.end() | ||
}) | ||
}) | ||
|
||
t.test('{only: true} without --only flag', function (t) { | ||
var file = require.resolve('./fixtures/only.js') | ||
var args = [ | ||
run, | ||
file | ||
] | ||
|
||
execFile(node, args, function (err, stdout, stderr) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
t.equal(stderr.trim(), '# Warning: "only" has {only: true} set but all tests are run') | ||
|
||
t.match(stdout, /^ok 1 - .*[\\\/]only.js/m) | ||
t.end() | ||
}) | ||
}) |