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

[Docs]: Difference between runner and testRunner? #14932

Closed
aaronvg opened this issue Mar 2, 2024 · 7 comments
Closed

[Docs]: Difference between runner and testRunner? #14932

aaronvg opened this issue Mar 2, 2024 · 7 comments

Comments

@aaronvg
Copy link

aaronvg commented Mar 2, 2024

Page(s)

https://jestjs.io/docs/configuration#runner-string

Description

Can you explain the difference between a runner and testRunner?

It seems a runner is what runs all the test runners no? From my own tinkering, testRunners got called once per test file, while a runner only gets called once with all tests across all files.

@SimenB
Copy link
Member

SimenB commented Mar 2, 2024

You can look at Jest like a sort task orchestrator. Runner then is what it manages (you can use this to e.g. run ESLint via Jest). A runner is executed once for every top level invocation (or watch mode re-run).

Test runner is used by Jest's builtin runner in order to run tests. The test runner is then either jest-circus or the legacy jest-jasmine, and that's what provides describe, test, expect to tests and reports back a result.

Does that make sense? Happy to take PRs to clarify the docs

@aaronvg
Copy link
Author

aaronvg commented Mar 2, 2024

by top-level invocation, you mean when you run the Jest CLI right? I'll submit a clarification PR

@aaronvg
Copy link
Author

aaronvg commented Mar 2, 2024

Which abstraction would help me set some context right before an individual test(..) or it(..) runs? Like setting an environment variable or asynclocalstorage for the things in the test to read?

Update: Found #7774 . What i really wanted was the test name so this should work I believe. If I have any other dynamic metadata (like some uuid I want to generate per test) I'll try the custom testRunner approach.

Copy link

github-actions bot commented Apr 1, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Apr 1, 2024
Copy link

github-actions bot commented May 2, 2024

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
Copy link

github-actions bot commented May 2, 2024

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

Copy link

github-actions bot commented Jun 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants