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

TypeError: Cannot read property 'prototype' of undefined instead of diff #8822

Closed
mschipperheyn opened this issue Aug 14, 2019 · 4 comments
Closed

Comments

@mschipperheyn
Copy link

mschipperheyn commented Aug 14, 2019

🐛 Bug Report

Jest throws a type error

TypeError: Cannot read property 'prototype' of undefined
at actual.then.result (../../node_modules/jest-jasmine2/node_modules/expect/build/index.js:176:63)

similar to reported here: #6730

To Reproduce

The test

return expect(
    mutate({
        query: MUTATION_INVITE_MEMBERS,
        variables: {
            id: defaultGroup.id,
            input: { ids: [otherSocialUser.id] },
        },
    }),
).resolves.toMatchObject({
    data: {
        social__inviteMembers: [
            {
                user: {
                    id: otherSocialUser.id,
                },
                status: 'INVITED',
                rsvpStatus: 'UNKNOWN',
            },
        ],
    },
});

The returned value

   {
        id: '957c9707-d293-4866-979e-7e2ac58a3324',
        group: { 
                 id: 'c7df05fe-c1a0-4c9e-b26f-817b7a0bb1bf' 
        },
        user: {
           id: 'a934391d-ace0-47ff-8aa4-1ec355527652',
           displayName: 'Marc Schipperheijn',
           gender: 'M' 
       },
        status: 'INVITED' }

The rsvpStatus key is missing.

Steps to reproduce the behavior:

Expected behavior

It show a diff instead of throwing an error.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
  npmPackages:
    jest: ^24.8.0 => 24.8.0 
@mschipperheyn
Copy link
Author

So, one thing I noticed is that jest-jasmnine2 on my system is 23.6.0.
However, when I force resolution to 24.8.0 I get this nasty error on all my tests:

TypeError: Expected throat size to be a number but got undefined

      at throat (../../node_modules/throat/index.js:34:13)
      at module.exports (../../node_modules/throat/index.js:76:12)
yarn why v1.17.3
[1/4] 🤔  Why do we have the module "jest-jasmine2"...?
[2/4] 🚚  Initialising dependency graph...
warning Resolution field "[email protected]" is incompatible with requested version "create-react-context@^0.2.1"
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "jest-jasmine2"
info Reasons this module exists
   - "workspace-aggregator-08ea9065-b69c-42a2-b01c-c7278146fca3" depends on it
   - Hoisted from "_project_#jest-config#jest-jasmine2"
   - Hoisted from "_project_#server#razzle#jest#jest-cli#jest-runner#jest-jasmine2"
info Disk size without dependencies: "936KB"
info Disk size with unique dependencies: "7.36MB"
info Disk size with transitive dependencies: "32.33MB"
info Number of shared dependencies: 108
=> Found "jest-runner#[email protected]"
info Reasons this module exists
   - "_project_#jest-runner" depends on it
   - Hoisted from "_project_#jest-runner#jest-config#jest-jasmine2"
info Disk size without dependencies: "648KB"
info Disk size with unique dependencies: "11.66MB"
info Disk size with transitive dependencies: "69.81MB"
info Number of shared dependencies: 262
=> Found "jest-cli#[email protected]"
info Reasons this module exists
   - "_project_#jest-cli#jest-config" depends on it
   - Hoisted from "_project_#jest-cli#jest-config#jest-jasmine2"
info Disk size without dependencies: "648KB"
info Disk size with unique dependencies: "11.66MB"
info Disk size with transitive dependencies: "69.81MB"
info Number of shared dependencies: 262
=> Found "@jest/core#[email protected]"
info Reasons this module exists
   - "_project_#jest-cli#@jest#core#jest-config" depends on it
   - Hoisted from "_project_#jest-cli#@jest#core#jest-config#jest-jasmine2"
info Disk size without dependencies: "648KB"
info Disk size with unique dependencies: "11.66MB"
info Disk size with transitive dependencies: "69.81MB"
info Number of shared dependencies: 262
=> Found "@jest/reporters#[email protected]"
info Reasons this module exists
   - "_project_#jest-cli#@jest#core#@jest#reporters#jest-runtime#jest-config" depends on it
   - Hoisted from "_project_#jest-cli#@jest#core#@jest#reporters#jest-runtime#jest-config#jest-jasmine2"
info Disk size without dependencies: "648KB"
info Disk size with unique dependencies: "11.66MB"
info Disk size with transitive dependencies: "69.81MB"
info Number of shared dependencies: 262
=> Found "@jest/test-sequencer#[email protected]"
info Reasons this module exists
   - "_project_#jest-runner#jest-config#@jest#test-sequencer#jest-runtime#jest-config" depends on it
   - Hoisted from "_project_#jest-runner#jest-config#@jest#test-sequencer#jest-runtime#jest-config#jest-jasmine2"
info Disk size without dependencies: "648KB"
info Disk size with unique dependencies: "11.66MB"
info Disk size with transitive dependencies: "69.81MB"
info Number of shared dependencies: 262

@SimenB
Copy link
Member

SimenB commented Aug 15, 2019

Unfortunate that razzle depends on an old version of jest. It doesn't handle hoisted deps properly (we've tried to fix that in in jest 24). What happens if you explicitly depend on jest and jest-config? The hoisting gods might fix your issue then.

@mschipperheyn
Copy link
Author

Add "jest-config": "^24.8.0", to the resolutions key solved it! Thanks!

@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

No branches or pull requests

2 participants