ipfs / aegir

AEgir - Automated JavaScript project building
https://ipfs.github.io/aegir
Other
97 stars 59 forks source link

bug: `aegir test --bail` doesn't adhere to build configuration #1488

Open SgtPooki opened 3 months ago

SgtPooki commented 3 months ago

Describe the bug

Running tests with npx aegir test --bail false flag will not trigger aegir build which would be otherwise triggered by npx aegir test

To Reproduce Steps to reproduce the behavior:

  1. Go to any project configured with aegir build and test, such as https://github.com/ipfs/helia-verified-fetch
  2. run npm run clean to ensure dist folder is removed
  3. run npm run test and see that tests run successfully after building
  4. run npm run clean to ensure that dist folder is removed
  5. run npm run test -- --bail false and see the below error message: Error: No test files found
image

Expected behavior I expect the same test flow to occur, though mocha should no longer bail for any given test.

Additional context

I have been running some tests with DEBUG="test*,test*:trace" npm run test -- -g 'abort-handling' and then running DEBUG="test*,test*:trace" npm run test -- -g 'abort-handling' --bail false while changing some things. When running tests without the bail flag, aegir builds my tests and then runs the tests as expected. With it, aegir does not rebuild the src & tests.

SgtPooki commented 3 months ago

Also noticed that we have an alias conflict -b is for both --bail and --build:

╰─ ✔ ❯ npm run test -- --help

> @helia/verified-fetch@1.3.3 test
> aegir test --help

aegir test

Test your code in different environments

Global Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]
  -d, --debug    Show debug output.                   [boolean] [default: false]

Options:
  -b, --build       Build the project before running the tests
                                                       [boolean] [default: true]
      --types       If a tsconfig.json is present in the project, run tsc.
                                                       [boolean] [default: true]
  -t, --target      In which target environment to execute the tests
  [array] [choices: "node", "browser", "webworker", "electron-main", "electron-r
  enderer", "react-native-android", "react-native-ios"] [default: ["node","brows
                                                               er","webworker"]]
  -w, --watch       Watch files for changes and rerun tests
                                                      [boolean] [default: false]
  -f, --files       Custom globs for files to test         [array] [default: []]
      --timeout     The default time a single test has to run
                                                       [number] [default: 60000]
  -g, --grep        Limit tests to those whose names match given pattern[string]
  -b, --bail        Mocha should bail once a test fails
                                                      [boolean] [default: false]
      --progress    Use progress reporters on mocha and karma
                                                      [boolean] [default: false]
      --cov         Enable coverage output. Output is already in Istanbul JSON f
                    ormat and can be uploaded directly to codecov.
                                                      [boolean] [default: false]
      --covTimeout  How long to wait for coverage collection. Workaround for htt
                    ps://github.com/ipfs/aegir/issues/1206
                                                       [number] [default: 60000]
achingbrain commented 2 months ago

The alias conflict is probably what's causing this 😢