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 tests for loading reporters w/ relative/absolute paths #2772

Closed
dasilvacontin opened this issue Apr 20, 2017 · 5 comments
Closed

Add tests for loading reporters w/ relative/absolute paths #2772

dasilvacontin opened this issue Apr 20, 2017 · 5 comments
Labels
type: feature enhancement proposal

Comments

@dasilvacontin
Copy link
Contributor

I'd like to have tests for the new feature added in #2659.

Gonna do this today after I review the rest of the un-released commits. Let me know if you want to tackle it for me.

@dasilvacontin dasilvacontin self-assigned this Apr 20, 2017
@sul4bh
Copy link
Contributor

sul4bh commented Apr 20, 2017

I can help with writing a test to cover #2659 if you give me some pointers on what to cover in the test.

@dasilvacontin
Copy link
Contributor Author

dasilvacontin commented Apr 20, 2017

@sul4bh Thanks!

It should cover:

  • using a relative path as the argument for the reporter option
  • using an absolute path as the argument for the reporter option

So maybe write a very short and useless reporter, and use this helper to execute the mocha binary, and check its output and that there haven't been any error:

/**
* Invokes the mocha binary on the code of the body of the function.
* Accepts an array of additional command line args to pass. The callback is
* invoked with a summary of the run, in addition to its output. The summary
* includes the number of passing, pending, and failing tests, as well as the
* exit code. Useful for testing different reporters.
*
* Example response:
* {
* pending: 0,
* passing: 0,
* failing: 1,
* code: 1,
* output: '...'
* }
*
* @param {function} fixture
* @param {array} args
* @param {function} fn
*/
runMochaFunction: function (fixture, args, fn) {
var path = resolveFixturePath(fixture.name + '.js' || 'tempfile.js');
args = args || [];
var fixtureContent = 'var fn = ' + fixture.toString() + '; fn()';
fs.writeFileSync(path, fixtureContent, 'utf8');
function cleanup () {
fs.unlink(path);
fn.apply(this, arguments);
}
invokeMocha(args.concat(['-C', path]), function (err, res) {
if (err) {
return cleanup(err);
}
cleanup(null, getSummary(res));
});
},
.

Ping me on Gitter if anything! :)

@sul4bh
Copy link
Contributor

sul4bh commented Apr 20, 2017

Awesome. I am on it!

@dasilvacontin
Copy link
Contributor Author

@sul4bh ❤️

@dasilvacontin
Copy link
Contributor Author

Closed via #2773.

@dasilvacontin dasilvacontin removed their assignment May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

3 participants