-
Notifications
You must be signed in to change notification settings - Fork 492
jest testing is not using config/polyfills.js
#136
Comments
[EDIT]: that didn't actually fix the problem. I'll see if I can work out what's causing this. |
@timswalling thanks, but i tried as what you said and it still failed |
@cyyyu I just realised it's still a problem in my setup too - my tests were passing because of an unrelated change, but the problem remained. I've retested using your exact steps above, and including plain JavaScript in the TypeScript transform does seem to work:
This isn't the configuration specified in the I'll keep looking... |
I've looked into this a bit more, and there are actually two issues in play:
The changes I've posted above do fix the problem, but it's not particularly idiomatic. The following code would be closer to the original
I'll create a PR to update |
@timswalling Thank you for investigating. Though I don't actually understand the root cause clearly, hopefully it can be fixed soon. |
@cyyyu I've opened a PR that will fix the issue for apps that haven't been ejected. If you've already ejected your app you'll need to replace the |
@timswalling It works! you do save my life. thanks! |
Hi, here I encountered a issue which is about testing.
Briefly: in a ejected project, jest is not using
config/polyfills.js
as itssetupFiles
, even it has been specified in package.json.Steps to Reproduce
create-react-app-typescript
yarn eject
window.anything = 'test'
toconfig/polyfills.js
expect(window.anything).toBe('test')
tosrc/App.test.tsx
Then it failed. See outputs below.
I could only reproduce it in a
create-react-app-typescript
project, whilecreate-react-app
projects worked fine.I also did the same in a
create-react-app
project, and I got the expected outputs.Please advise. thanks in advance.
The text was updated successfully, but these errors were encountered: