aegir
aegir copied to clipboard
bug [test] target: environment should ignore other environment specific tests
Describe the bug The test runner produces the following pattern for testing:
<test-cmd> [
'test/<target-env>.{js,cjs,mjs}',
'test/**/*.spec.{js,cjs,mjs}',
'dist/test/<target-env>.{js,cjs,mjs}',
'dist/test/**/*.spec.{js,cjs,mjs}',
]
but *.spec.{js,cjs,mjs} already includes everything, so if the environment is node it would also end up running test for browser it should ignore browser
To Reproduce
in the tests folder, create test:
node.spec.jsbrowser.spec.jstest.spec.js
Run tests: aegir test --target node.
Expected behavior
Only the following tests should Run:
node.spec.jstest.spec.js
Instead all three run.
Most modules that use aegir have isomorphic tests that match *.spec.js. Some modules do not, they have, for example node.js that imports node tests and browser.js that imports browser tests. These environment-specific tests aren't usually named *.spec.js.
One of the things that has bothered me about the current method of using node.js or browser.js files is it is difficult to run individual test files for given environments.
For example, if I wanted to run the tests for "build" in aegir, I'd have to run mocha directly against the test file after making sure all the usual set up is correct.
So, rather than running the tests just for build I run the tests for everything just to run the tests for build.
it is difficult to run individual test files for given environments
You can do something like this:
$ aegir test -t node --grep 'build'