-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for grep option programmatic #188
Add test for grep option programmatic #188
Conversation
@1999 Please check code carefully as I am really new with JS. I assume some things can be done by another way. Let me know if it is true and I need change code. Thanks and waiting for your feed back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done! When we merge this PR one more mocha
option would be supported 🍷🎉
test/grep/indexProgrammatic.js
Outdated
|
||
process.on('exit', () => { | ||
var jsonResult = JSON.parse(output); | ||
assert.strictEqual(jsonResult.stats.passes, 3, 'Tests number is wrong. Expected 3. Actual: ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess having 3 arguments here is superfluous since assert.strictEqual gives quite a clear error.
test/grep/indexProgrammatic.js
Outdated
|
||
mocha.run(function() { | ||
process.stdout.write = write; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 17-25 are probably not needed: you're not checking the output
and it looks like you just need to swallow the output, right? In this case you can use SilentReporter from this file. The code in this case should look smth close to this:
const SilentReporter = require('../util/silent-reporter');
mocha
.addFile(`${__dirname}/tests/test.js`)
.addFile(`${__dirname}/tests/test1.js`)
.timeout(10000)
.grep('grep')
.reporter(SilentReporter);
test/index.sh
Outdated
@@ -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' test/grep/indexProgrammatic.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep option - programmatic API support
would be a bit nicer
- change body of test - rename test name
@1999 thanks for your comments. Changed accordingly. Take a look and give more points if exist, please! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just awesome. Thank you for contributing to mocha-parallel-tests
!
-add test for grep option programmatic