I want to make tests of my create-react-app using jest.
One of node_modules have test-error,
but I don't want jest to work with node_modules folder.
In the documentation I found configuration property "collectCoverageFrom" and tried to use itin my package.json:
....
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom ",
"eject": "react-scripts eject"
},
"jest": {
"collectCoverageFrom": [
"!/node_modules/*"
]
}
But there is nothing changed.
There is nothing with coverage.
One of your components is using react-mic
package provides access to audio through window.AudioContext
.
You have different ways to solve it.
You may mock window.AudioContext
. It would be really hard to achieve. I don't really suggest you doing that.
You can mock react-mic
module. That's much more achievable than #1 but still quite hard.
You can rely on shallow()
in your tests. So your will never need to mock anything related to Audio at all. I'd like to suggest you doing that way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With