Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouping tests by file #4644

Closed
KSXGitHub opened this issue Apr 6, 2020 · 3 comments · Fixed by #10428
Closed

Grouping tests by file #4644

KSXGitHub opened this issue Apr 6, 2020 · 3 comments · Fixed by #10428
Labels
cli related to cli/ dir suggestion suggestions for new features (yet to be agreed)

Comments

@KSXGitHub
Copy link
Contributor

KSXGitHub commented Apr 6, 2020

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.

Alternative Proposals

  1. Show file names alongside test case.
  2. Display a tree of file names and test case. File names are branches, and test cases are leafs.
  3. Create a Deno.testGroup function that acts like describe in Jest, use it in .deno.test.ts to wrap import line of a test file.
  4. Log test file names before execution (similar to cargo test).
@bartlomieju
Copy link
Member

Alternative Proposals

  1. Show file names alongside test case.
  2. 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

  1. Create a Deno.testGroup function that acts like describe in Jest, use it in .deno.test.ts to 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.

@KSXGitHub
Copy link
Contributor Author

If #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?

@KSXGitHub
Copy link
Contributor Author

There is an easier solution: log test file names before import 'test-file'. This would produce a result similar to cargo test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir suggestion suggestions for new features (yet to be agreed)
Projects
None yet
2 participants