How can I use Mocha without removing Ava?

332 views Asked by At

One of my co-workers added this Ava package to our setup, and it's done something I've never seen a Node package do before: interfere with other packages! Now when I try to run Mocha I get:

$ node_modules/mocha/bin/mocha test/
Test files must be run with the AVA CLI:

    $ ava node_modules/mocha/bin/_mocha

I get that Ava would like to run my Mocha tests, but if I wanted that I'd run ava mocha not mocha. And because a co-worker is using it I can't simply uninstall the package.

Is there any way I can run plain Mocha tests on a machine with Ava installed?

1

There are 1 answers

0
Dan Prince On BEST ANSWER

One of the files in test/ imports ava and the imported code will recognise that it's not being run with the correct tooling and throw an error.

Might be worth subdividing your test/ directory to keep tests associated with their respective runners.

test/
  ava/
    SomeAvaTests.js
  mocha/
    SomeMochaTests.js

This way you can safely run mocha test/mocha/ and vice versa without worrying about treading on each other's toes.