Search code examples
javascriptunit-testingintern

Intern - define different commands / arguments to run different tests


I have a project with 2 functional Suites, the structure is like this:

- /tests
--- /sign
------ sign.js
--- /buy
------ buy.js
--- intern.js
- /node_modules
- ....

On my intern.js I have this

//...
functionalSuites: [ 'tests/sign/sign', 'tests/buy/buy'],  
//...

And to run the test intern-runner config=tests/intern

So far so good, 2/2 tests passed.

I would like to know if it's possible to pass some arguments to execute only a part of the functionalSuites

ex:

intern-runner config=tests/intern --sign

And somehow it would run only the functionalSuite tests/sign/sign

And if I pass intern-runner config=tests/intern --all it would run all functionalSuite tests.

Thank you


Solution

  • You should use the grep parameter introduced in Intern 2.1 release announce. With grep you can target one specific test or a class of tests depending on your naming convention.

    In our case, the functionSuites settings contains only 'test/functional/**/* to be sure that no functional test is forgotten by the CI process. And we use the grep attribute during the script development.