Skip to content

Commit

Permalink
Add test for grep option programmatic (#188)
Browse files Browse the repository at this point in the history
* - add test for grep option programmatic

* Update according comments to pull request:
- change body of test
- rename test name
  • Loading branch information
hennadiib authored and 1999 committed Aug 1, 2018
1 parent bfcd4fe commit fe999de
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test/grep/README
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Check that --grep flag run tests by string pattern 'grep'
- index.js check that --grep flag run tests by string pattern 'grep'
- indexProgrammatic.js check that --grep flag run tests by string pattern 'grep' with programmatic using mocha
3 changes: 1 addition & 2 deletions test/grep/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ exec(libExecutable + ' -R json --grep grep test/grep/tests', {
process.exit(1);
}

assert.strictEqual(jsonReporterOutput.stats.passes, 3, 'Tests number is wrong. Expected 3. Actual: '
+ jsonReporterOutput.stats.passes);
assert.strictEqual(jsonReporterOutput.stats.passes, 3);
});
21 changes: 21 additions & 0 deletions test/grep/indexProgrammatic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node

'use strict';

const assert = require('assert');
const MochaParallelTests = require('../../dist/main/mocha').default;
const { setProcessExitListeners } = require('../../dist/util');
const SilentReporter = require('../util/silent-reporter');

setProcessExitListeners();

const mocha = new MochaParallelTests;
mocha.addFile(`${__dirname}/tests/test.js`)
.addFile(`${__dirname}/tests/test1.js`)
.timeout(10000)
.grep('grep')
.reporter(SilentReporter);

mocha.run().on('end', function () {
assert.strictEqual(this.stats.passes, 3);
});
1 change: 1 addition & 0 deletions test/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ test 'subprocess exits before sending an end message' test/no-subprocess-end/ind
test 'unhandled rejections should not force subprocess to exit' test/q-promises/index.js
test 'uncaught exceptions should not force subprocess to exit' test/uncaught-exception/index.js
test 'grep option' test/grep/index.js
test 'grep option - programmatic API support' test/grep/indexProgrammatic.js

echo "Passes: $PASSES Failes: $FAILES"
echo ""
Expand Down

0 comments on commit fe999de

Please sign in to comment.