Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Cannot read property 'some' of undefined" when running tests #10489

Closed
bschlenk opened this issue Sep 8, 2020 · 9 comments · Fixed by #10578
Closed

Getting "Cannot read property 'some' of undefined" when running tests #10489

bschlenk opened this issue Sep 8, 2020 · 9 comments · Fixed by #10578

Comments

@bschlenk
Copy link
Contributor

bschlenk commented Sep 8, 2020

🐛 Bug Report

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)

To Reproduce

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.

Expected behavior

Tests should work and pass.

Link to repl or repo (highly encouraged)

https://github.com/bschlenk/jest-some-repro

envinfo

  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 
@jpabeem
Copy link

jpabeem commented Sep 9, 2020

Running into the same issue here, can confirm. Any update(s) on this so far?

@josechavarriacr
Copy link

@jpabeem I downloaded your repo, I running it and work using yarn.
node version : v10.19.0
yarn version: 1.22.4

@josechavarriacr
Copy link

josechavarriacr commented Sep 10, 2020

Btw, I fixed this problem running npm install --save-dev babel-jest regenerator-runtime
#3114 (comment)

@bschlenk
Copy link
Contributor Author

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.

@phawxby
Copy link
Contributor

phawxby commented Sep 10, 2020

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

@raimoa1
Copy link

raimoa1 commented Sep 20, 2020

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.

@AndreiRailean
Copy link

AndreiRailean commented Sep 22, 2020

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

@jooj123
Copy link

jooj123 commented Nov 16, 2020

Updating jsdom fixed this for me 👍

sidequestlegend added a commit to sidequestlegend/ngx-unused-css that referenced this issue Nov 19, 2020
I had an issue with a bunch of errors like this: 

```
TypeError: Cannot read property 'some' of undefined
                                                                                       
      at Object.exports.install (node_modules/whatwg-url/dist/URL.js:84:20)
```

jestjs/jest#10489 (comment) - shows that its an issue with jsdom 16.2.2. I tested by forcing the next newer version 16.3.0 which fixed the problem, so I propose that this dependency be updated.
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants