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

Adding Mocha within Gobble #34

Closed
joshbedo opened this issue Feb 18, 2015 · 2 comments
Closed

Adding Mocha within Gobble #34

joshbedo opened this issue Feb 18, 2015 · 2 comments

Comments

@joshbedo
Copy link

Is there a way to run mocha tests within Gobble? So a build would re-run tests when changes happened.

@evs-chris
Copy link
Contributor

There isn't really a straightforward built-in way to do that right now, but that is a feature that's being looked into. See #31. That's on my short list of things to do once I get some breathing room, and I think a test runner of some sort would be one of the first transforms to get added.

You can accomplish this now by writing a transform that runs the tests and bails if the tests fail. Then for your final target, gobble the test step as well. Roughly:

var src = gobble('sources').transform('compile-or-whatever');
// test can affect the build, but it doesn't pass any of its files on - only gets run when src or 'tests' changes
var test = gobble([src, gobble('tests')]).transform((indir, outdir, options, done) => {
  var mocha = new Mocha({ ... });
  return this.sander.lsr(indir, 'tests').then(files => files.forEach(f => mocha.addFile(f))).then(() => {
    mocha.run(errs => if (errs > 0) throw new Error('Tests failed'))
  });
});
module.exports = gobble([src, test]);

@IvanSanchez
Copy link
Member

Closing because https://github.com/Victorystick/gobble-mocha

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

No branches or pull requests

3 participants