NomicFoundation/hardhat

Expanding the functionality of the `test` task

alcuadrado opened this issue · 7 comments

This are frequently requested features that we should implement:

  • Accept directories, not just files, as arguments
  • add a --bail option that makes mocha stop in the first failure
  • add a --grep option to filter tests

The last to ones are actually mocha arguments, but as our task system is more generic than mocha (e.g. a plugin could use jest instead), we should not communicate them as being mocha arguments. Maybe we should use different names.

Mocha 8 (a drop-in replacement for 7 for the the most part) also supports parallel tests - it'd be great if we had this and each test file got their own Hardhat node.

Running a command such as

find . -maxdepth 3 -type d \( -name "node_modules" \) -prune -false -o -name "test" | xargs -i{} sh -c "( cd {}/../; npx mocha --bail --grep \"The filter phrase that you want\" --recursive \"test/**/*.ts\" )"

Could do the trick, but I am not sure if ./scripts/run-tests.js should be modified by using yargs package or not.

@sisco0 that script is for running our internal tests. This issue is about changing how the test task works.

I understand @fvictorio , I am not sure if sisco0@5459840 is the expected behavior, but I am testing it with --grep.

Just came here to request this feature (--grep specifically) and I see that #2359 implemented it a week ago. Nice!

Would be great though if --invert was also available. Same with --exclude, though not having that one is easier to work around with find.

Current issue could be closed as mentioned by @cameel . Great work team.

Can you create issues for the flags/arguments that you think are worth adding?

I'm closing this issue as it's too generic to be useuful.