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

Allow watcher plugins to mark any test to be run #10163

Closed
thomasmichaelwallace opened this issue Jun 12, 2020 · 4 comments
Closed

Allow watcher plugins to mark any test to be run #10163

thomasmichaelwallace opened this issue Jun 12, 2020 · 4 comments

Comments

@thomasmichaelwallace
Copy link

🚀 Feature Proposal

Provide a way for Watcher Plugins to add test suites to be run.

This could be done by:

  • adding a "add test suite" to the callback for jestHooks.fileChanged
  • provide a new hook like jestHooks.mustRunTestSuite(testSuiteInfo)
  • change the jestHooks.shouldRunTestSuite(testSuiteInfo) behaviour so that it is called for all tests (not just those not already filtered out).

Motivation

This would allow tests to be run on conditions outside of the watcher's scope, such as when files used to dynamically build tests are changed, or when files are indirectly imported.

Example

We have two examples in the code base where we're currently updating a comment in tests so that the 'on-change' behaviour runs them:

  • Tests that rely on generated graphql schema stitched together from a glob pattern that is "imported" independently using fs.readFileSync
  • Tests that are generated by reading a directory of ".json" template files.

Pitch

At the moment these use cases can't be achieved with the existing watcher plugin behaviour.

My two example use-cases is likely to be too specific to be directly supported by core. But by extending the watcher, you enable people in similar situations (where not all files that change a test are obvious to hastemap) to write the plugins they need.

@github-actions
Copy link

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

@github-actions github-actions bot added the Stale label Feb 25, 2022
@thomasmichaelwallace
Copy link
Author

Haha- fair enough github-actions!

I guess no one else liked it 😛

@SimenB
Copy link
Member

SimenB commented Feb 25, 2022

Sorry! 😬

See #12496 for motivation.


While I cannot guarantee anything regarding if it'll get merged or not, I'm happy to review a PR adding support for this. Empowering watch plugins sounds attractive to me.

@github-actions
Copy link

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 Mar 28, 2022
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