Hi guys!
I've made setup without create-react-app and when I try to run tests I got error:
Test is very simple :
it('first test', () => {
expect(123).toBe(123)
})
I'd like to be able to pass my tests
I see this also
related to jsdom/jsdom#2304
You can set the testURL
of the jest configuration like this:
"jest": {
"verbose": true,
"testURL": "http://localhost/"
}
Ok. The fix is to set testURL: "http://localhost/" in jest config.
But I have another problem. All running process is very slow, It last about 5-7 sec even if I run my tests with --watch.
Anyone knows how to increase performance?
Fast fix: I changed my Jest version from "23.4.1" to "22.4.1"
Duplicate: https://github.com/facebook/jest/issues/6766
For anyone just starting to use Jest and running into this error, this is how you define a Jest configuration: https://jestjs.io/docs/en/configuration.html
Update: setting testURL works. I had a different problem, with my babelrc.
When I set testURL, I get a new error at all instances of import Enzyme
SyntaxError: Unexpected token import
Not sure if this is related to react-sass-starterkit test setup or not, since this is my first time trying to do react testing with jest...
If you are using jsdom, make sure you include url
const dom = new JSDOM(``, {
url: "https://example.org/",
});
If use vue-cli, only necesary agregate to MyProjectVueCli/test/unit/jest.config.js
..
..
collectCoverageFrom: [
..
'!**/node_modules/**'
],
**testURL:"http://localhost:8080"**
}
related to jsdom/jsdom#2304
You can set the
testURL
of the jest configuration like this:"jest": { "verbose": true, "testURL": "http://localhost/" }
Ya it solve my issue
Most helpful comment
related to jsdom/jsdom#2304
You can set the
testURL
of the jest configuration like this: