You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently installed react-app-rewired to allow me to modify jest's testEnvironment while using the jest test runner without getting the CRA error that blocks it from running. I currently use two methods to run my tests: npm run test, which uses the jest test runner to run my test suite. This, for some reason, works just fine. And my IDE (Pycharm), which also uses the Jest test runner, but for some reason throws an error:
Out of the box, Create React App only supports overriding these Jest options:
• clearMocks
• collectCoverageFrom
• coveragePathIgnorePatterns
• coverageReporters
• coverageThreshold
• displayName
• extraGlobals
• globalSetup
• globalTeardown
• moduleNameMapper
• resetMocks
• resetModules
• restoreMocks
• snapshotSerializers
• testMatch
• transform
• transformIgnorePatterns
• watchPathIgnorePatterns.
These options in your package.json Jest configuration are not currently supported by Create React App:
• testEnvironment
• verbose
If you wish to override other Jest options, you need to eject from the default setup. You can do so by running npm run eject but remember that this is a one-way operation. You may also file an issue with Create React App to discuss supporting more options out of the box.
Process finished with exit code 1
If I uncomment the "jest" entry in my package.json file (see below), then the PyCharm test runner works just fine, but my npm run test output gives errors, which is why I modified package.json in the first place:
FAIL src/components/login/Login.test.js
● Should render succesfully with some hard-coded value props
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string.
Consider using the "jsdom" test environment.
ReferenceError: document is not defined
13 | let root = null;
14 | beforeEach(() => {
> 15 | container = document.createElement('div');
| ^
16 | document.body.appendChild(container);
17 | })
18 |
at Object.<anonymous> (src/components/login/Login.test.js:15:5)
/* config-overrides.js */
module.exports = function override(config, env) {
//do stuff with the webpack config...
return config;
}
My understanding was that this package allows me to override CRA Jest options directly from package.json, as the documentation explicitly indicates in the section on jest testing. The whole reason I installed this package was to solve this problem, am I missing something obvious? Forgive my ignorance if I'm doing something obviously stupid to you, I just started working with JS a couple weeks ago.
The text was updated successfully, but these errors were encountered:
I recently installed
react-app-rewired
to allow me to modify jest'stestEnvironment
while using the jest test runner without getting the CRA error that blocks it from running. I currently use two methods to run my tests:npm run test
, which uses the jest test runner to run my test suite. This, for some reason, works just fine. And my IDE (Pycharm), which also uses the Jest test runner, but for some reason throws an error:If I uncomment the "jest" entry in my
package.json
file (see below), then the PyCharm test runner works just fine, but mynpm run test
output gives errors, which is why I modifiedpackage.json
in the first place:package.json
:config-override
:My understanding was that this package allows me to override CRA Jest options directly from package.json, as the documentation explicitly indicates in the section on jest testing. The whole reason I installed this package was to solve this problem, am I missing something obvious? Forgive my ignorance if I'm doing something obviously stupid to you, I just started working with JS a couple weeks ago.
The text was updated successfully, but these errors were encountered: