-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
chore: mock stealthy-require in tests #9855
Conversation
packages/jest-runtime/src/index.ts
Outdated
@@ -1273,7 +1273,9 @@ class Runtime { | |||
moduleRequire.resolve = resolve; | |||
moduleRequire.cache = (() => { | |||
const notPermittedMethod = () => { | |||
console.warn('`require.cache` modification is not permitted'); | |||
this._environment.global.console.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimenB, looks reasonable. We could move up notPermittedMethod
helper to the jest-resolve
root and wrap it with once
, so we get just one warning until jest-resolve
reload.
@@ -8,3 +8,6 @@ | |||
// Some of the `jest-runtime` tests are very slow and cause | |||
// timeouts on travis | |||
jest.setTimeout(70000); | |||
|
|||
// this module does some funky stuff with `require.cache`, flooding the terminal with output | |||
jest.mock('stealthy-require', () => (_, m) => m()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ yarn why stealthy-require
=> Found "[email protected]"
info Reasons this module exists
- "_project_#jest-environment-jsdom#jsdom#request-promise-native" depends on it
- Hoisted from "_project_#jest-environment-jsdom#jsdom#request-promise-native#stealthy-require"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimenB should it be a best practice recommended for everyone?
…pshots * upstream/master: (39 commits) Prints the Symbol name into the error message with a custom asymmetric matcher (jestjs#9888) Show coverage of sources related to tests in changed files (jestjs#9769) fix: don't /// <reference types="jest" /> (jestjs#9875) noCodeFrame respects noStackTrace (jestjs#9866) chore: update example to [email protected] (jestjs#9746) Improve source map handling when instrumenting transformed code (jestjs#9811) Update .vscode/launch.json settings (jestjs#9868) chore: verify all packages have the same engine requirement (jestjs#9871) fix: pass custom cached realpath function to `resolve` (jestjs#9873) chore: mock stealthy-require in tests (jestjs#9855) chore: update resolve (jestjs#9872) chore: run CircleCI on node 14 (jestjs#9870) Add an option to vscode settings to always use workspace TS (jestjs#9869) fix(esm): handle parallel imports (jestjs#9858) chore: run CI on Node 14 (jestjs#9861) feat: add `@jest/globals` package for importing globals explici… (jestjs#9849) chore: bump resolve package (jestjs#9859) chore(runtime): simplify `createJestObjectFor` (jestjs#9857) chore: fix symlink creation failures on windows in tests (jestjs#9852) chore: skip mercurial tests when no hg installed (jestjs#9840) ...
…pshots * upstream/master: (39 commits) Prints the Symbol name into the error message with a custom asymmetric matcher (jestjs#9888) Show coverage of sources related to tests in changed files (jestjs#9769) fix: don't /// <reference types="jest" /> (jestjs#9875) noCodeFrame respects noStackTrace (jestjs#9866) chore: update example to [email protected] (jestjs#9746) Improve source map handling when instrumenting transformed code (jestjs#9811) Update .vscode/launch.json settings (jestjs#9868) chore: verify all packages have the same engine requirement (jestjs#9871) fix: pass custom cached realpath function to `resolve` (jestjs#9873) chore: mock stealthy-require in tests (jestjs#9855) chore: update resolve (jestjs#9872) chore: run CircleCI on node 14 (jestjs#9870) Add an option to vscode settings to always use workspace TS (jestjs#9869) fix(esm): handle parallel imports (jestjs#9858) chore: run CI on Node 14 (jestjs#9861) feat: add `@jest/globals` package for importing globals explici… (jestjs#9849) chore: bump resolve package (jestjs#9859) chore(runtime): simplify `createJestObjectFor` (jestjs#9857) chore: fix symlink creation failures on windows in tests (jestjs#9852) chore: skip mercurial tests when no hg installed (jestjs#9840) ...
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
As mentioned here: #9841 (comment)
This makes me think that we might want to rethink the warning... Is it safe to include this change?
@antongolub @thymikee @jeysal would love your thoughts
EDIT: One thing we can do is only warn once per
jest-runtime
(meaning per test file). Better than potentially flooding the output at leastTest plan
Green CI without flooded output