Currently, all tests from different test file are printed as if they are all from one file. This could be a problem on a large test suite where developer needs to find failed test case/file.
In Jest, tests are grouped per file. By default, only file names and names of failed tests are shown.
Deno.testGroup function that acts like describe in Jest, use it in .deno.test.ts to wrap import line of a test file.cargo test).Alternative Proposals
- Show file names alongside test case.
- Display a tree of file names and test case. File names are branches, and test cases are leafs.
Test cases are registered programatically during runtime using Deno.test() API so it would require crufty solution like creating error and looking up filename in the stack trace - but that's really not reliable, eg. in cli/js/tests/ default Deno.test() API is wrapped in unitTest function - trying to sniff out file name from stack trace would always return unit_test_runner.ts
- Create a
Deno.testGroupfunction that acts likedescribein Jest, use it in.deno.test.tsto wrap import line of a test file.
Not long ago there was discussion about adding something like test suite to test framework, but it was decided that it's left for 3rd party libs to implement.
If https://github.com/denoland/deno/issues/4366 is implemented, doing this would be much easier.
But for now, how about altering Deno.test itself in .deno.test.ts to display different file names?
There is an easier solution: log test file names before import 'test-file'. This would produce a result similar to cargo test.
Most helpful comment
There is an easier solution: log test file names before
import 'test-file'. This would produce a result similar tocargo test.