I\'ve come up against this issue Invalid URL is thrown when requiring systemjs in jest test cases
One of the last comments suggests
\"manipulate the jsdom instan
If you are using jsdom
(ver 11.12.0) without jest
(e.g. with ava + enzyme
)
then you can set url in jsdom config file
File src/test/jsdom-config.js
const jsdom = require('jsdom') // eslint-disable-line
const { JSDOM } = jsdom
const dom = new JSDOM('
', {
url: 'http://localhost/',
referrer: 'https://example.com/',
contentType: 'text/html',
userAgent: 'Mellblomenator/9000',
includeNodeLocations: true,
storageQuota: 10000000,
})
global.window = dom.window
global.document = window.document
global.navigator = window.navigator
AVA settings in package.json
{
...
"scripts": ...
...
"ava": {
"babel": "inherit",
"files": [
"src/**/*.test.js"
],
"verbose": true,
"require": [
"babel-register",
"ignore-styles",
"./src/test/jsdom-setup.js",
"./src/test/enzyme-setup.js"
]
}
}