-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[JEST] globalSetup and globalTeardown #8709
Comments
Same here, any update? |
@abrahamsaanchez or @lidanh can you provide a repo where this is happening? I can't seem to replicate on my side? |
this is the intended experience with jest. the global setup/teardown runs outside of jest. so using things like moduleNameMappers doesn't work as specified here. Only issue is they expect a tsconfig.json to contain the paths, where nx paths are contained in tsconfig.base.json.
WkMac-c8xtI3hO.0225.mp4
actually I can add it to the preset so it'll be included when running jest directory or nx. 🎉 |
explain using tsconfig-paths/register and TS_NODE_PROJECT to allow usage of tsconfig path aliases within the jest global setup/teardown files ISSUES CLOSED: #8709
auto register tsconfig paths in jest preset to allow for global setup/teardown files to reference other libs as needed ISSUES CLOSED: #8709
auto register tsconfig paths in jest preset to allow for global setup/teardown files to reference other libs as needed ISSUES CLOSED: #8709
auto register tsconfig paths in jest preset to allow for global setup/teardown files to reference other libs as needed ISSUES CLOSED: #8709
…global setup/teardown Jest global setup/teardown scripts run before path aliaes are mapped, so the path resigstration must happen in the userland global scripts that are set to run initially the thought of doing this within the jest executor was thought, but this will provide an inconsistent way to running tests if the tests are run via an editor plugin or calling `jest` directly; therefore, it's deferred to register the paths within userland files that are needing the paths to be registered in order to allow for proper handling (cleanup) and not to overcall unneeded features when global scripts are not in use for those not using the feature. ISSUES CLOSED: #8709
…global setup/teardown Jest global setup/teardown scripts run before path aliaes are mapped, so the path resigstration must happen in the userland global scripts that are set to run initially the thought of doing this within the jest executor was thought, but this will provide an inconsistent way to running tests if the tests are run via an editor plugin or calling `jest` directly; therefore, it's deferred to register the paths within userland files that are needing the paths to be registered in order to allow for proper handling (cleanup) and not to overcall unneeded features when global scripts are not in use for those not using the feature. ISSUES CLOSED: #8709
…ries (#9483) * docs(testing): add example on how to use ts path aliases within jest global setup/teardown Jest global setup/teardown scripts run before path aliaes are mapped, so the path resigstration must happen in the userland global scripts that are set to run initially the thought of doing this within the jest executor was thought, but this will provide an inconsistent way to running tests if the tests are run via an editor plugin or calling `jest` directly; therefore, it's deferred to register the paths within userland files that are needing the paths to be registered in order to allow for proper handling (cleanup) and not to overcall unneeded features when global scripts are not in use for those not using the feature. ISSUES CLOSED: #8709 * cleanup(testing): test the usage of jest global scripts to ensure no regressions streamline e2e jest project testing and update global tests to test global functions are working as intended
The link is down. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
When you use
globalSetup
orglobalTeardown
in the jest configuration, the imports with custom aliases are throwing an error.Expected Behavior
I should be able to import from libraries inside those files.
Steps to Reproduce
globalSetup
into the jest.config file -> globalSetup: '/tests/setup.ts',setup.ts
file, import the generated library.Failure Logs
Environment
The text was updated successfully, but these errors were encountered: