Running jest when [email protected] is installed results in the error:
TypeError: Cannot read property 'some' of undefined
at Object.exports.install (node_modules/whatwg-url/dist/URL.js:84:20)
Steps to reproduce the behavior:
Install jest, but make sure the jsdom pulled in by jest-environment-jsdom is 16.2.2.
$ npm ls jsdom
[email protected] /Users/bschlenk/Code/jest-repro
βββ¬ [email protected]
βββ¬ @jest/[email protected]
βββ¬ [email protected]
βββ¬ [email protected]
βββ [email protected]
FWIW, tests seem to pass when [email protected] is used, but jest-environment-jsdom has the version set to ^16.2.2.
Tests should work and pass.
https://github.com/bschlenk/jest-some-repro
System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v12.16.1/bin/npm
npmPackages:
jest: ^26.4.2 => 26.4.2
Running into the same issue here, can confirm. Any update(s) on this so far?
@jpabeem I downloaded your repo, I running it and work using yarn.
node version : v10.19.0
yarn version: 1.22.4
Btw, I fixed this problem running npm install --save-dev babel-jest regenerator-runtime
https://github.com/facebook/jest/issues/3114#issuecomment-383130334
Itβll work using yarn because yarn doesnβt read the package-lock.json file. The issue only happens when using [email protected], which is pinned in package-lock.
Can confirm the bug is reproducible from the repo above.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\PHawx\Downloads\jest-some-repro-master> npm -v
6.14.6
PS C:\Users\PHawx\Downloads\jest-some-repro-master> node -v
v12.18.3
PS C:\Users\PHawx\Downloads\jest-some-repro-master> npm install
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 775 packages from 343 contributors and audited 776 packages in 31.697s
21 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
PS C:\Users\PHawx\Downloads\jest-some-repro-master> npm run test
> [email protected] test C:\Users\PHawx\Downloads\jest-some-repro-master
> jest
FAIL ./app.test.js
β Test suite failed to run
TypeError: Cannot read property 'some' of undefined
at Object.exports.install (node_modules/whatwg-url/dist/URL.js:84:20)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.038 s, estimated 3 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\PHawx\AppData\Roaming\npm-cache\_logs\2020-09-10T11_01_59_818Z-debug.log
I know this bug is specifically about 16.2.2 version, but I was tired of seeing the error in failed tests went ahead and updated. Apparently it doesn't happen anymore after updating jsdom to 16.4.0.
Came here because I also had a similar issue. We use yarn so our setup is a little different. After bashing my had at jsdom, babel and other packages with no success, I found that deleting my yarn.lock forced slightly newer package versions to be installed, which ended up resolving this issue. We're still on yarn v1.22.5
Updating jsdom fixed this for me π
Most helpful comment
Running into the same issue here, can confirm. Any update(s) on this so far?