aegir icon indicating copy to clipboard operation
aegir copied to clipboard

bug [test] target: environment should ignore other environment specific tests

Open whizzzkid opened this issue 3 years ago • 3 comments

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.js
  • browser.spec.js
  • test.spec.js

Run tests: aegir test --target node.

Expected behavior

Only the following tests should Run:

  • node.spec.js
  • test.spec.js

Instead all three run.

whizzzkid avatar Oct 20 '22 05:10 whizzzkid

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.

achingbrain avatar Oct 23 '22 20:10 achingbrain

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.

ronald-mz avatar Jun 09 '23 15:06 ronald-mz

it is difficult to run individual test files for given environments

You can do something like this:

$ aegir test -t node --grep 'build'

achingbrain avatar Jun 10 '23 07:06 achingbrain