Skip to content
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

Conversation

hennadiib
Copy link
Contributor

-add test for grep option programmatic

@hennadiib
Copy link
Contributor Author

@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.

Copy link
Collaborator

@1999 1999 left a 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 🍷🎉


process.on('exit', () => {
var jsonResult = JSON.parse(output);
assert.strictEqual(jsonResult.stats.passes, 3, 'Tests number is wrong. Expected 3. Actual: '
Copy link
Collaborator

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.


mocha.run(function() {
process.stdout.write = write;
});
Copy link
Collaborator

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
Copy link
Collaborator

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
@hennadiib
Copy link
Contributor Author

@1999 thanks for your comments. Changed accordingly. Take a look and give more points if exist, please!
(Will update my profile with name)

Copy link
Collaborator

@1999 1999 left a 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!

@1999 1999 merged commit fe999de into mocha-parallel:master Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants