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
{{ message }}
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
Hi, here I encountered a issue which is about testing.
Briefly: in a ejected project, jest is not using config/polyfills.js as its setupFiles, even it has been specified in package.json.
Steps to Reproduce
generate a new project with create-react-app-typescript
do yarn eject
add window.anything = 'test' to config/polyfills.js
add expect(window.anything).toBe('test') to src/App.test.tsx
run test
Then it failed. See outputs below.
FAIL src/App.test.tsx
● renders without crashing
expect(received).toBe(expected)
Expected value to be (using ===):
"string"
Received:
undefined
Difference:
Comparing two different types of values. Expected string but received undefined.
at Object.<anonymous> (src/App.test.tsx:9:27)
at Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
at <anonymous>
✕ renders without crashing (306ms)
I could only reproduce it in a create-react-app-typescript project, while create-react-app projects worked fine.
I also did the same in a create-react-app project, and I got the expected outputs.
PASS src/App.test.js
✓ renders without crashing (19ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.163s
Ran all test suites related to changed files.