-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 'version' of undefined #735
Comments
Hi @adamransom! |
I believe 16.13.1! |
@adamransom I tried to reproduce this one with CRA (I upgraded to |
Interesting, thanks for trying to reproduce. I will attempt a reproduction in codesandbox, but it sounds like it may be something a bit more subtle in our config/package dependencies! |
Maybe I'll be able to understand this one through the package.json if you want to attach it. |
Good idea, here it is: https://pastebin.com/raw/75Tu9Jfz |
Two questions:
|
I also can't create a repro on codesandbox, so I guess it is something very fiddly with my config. |
Full error, in case it is helpful: 4 TypeError: Cannot read property 'version' of undefined
5
6 1 | import React from "react";
7 2 | import "@testing-library/jest-dom/extend-expect";
8 > 3 | import { fireEvent, render } from "@testing-library/react";
9 | ^
10 4 | import userEvent from "@testing-library/user-event";
11 5 | import { Router } from "react-router-dom";
12 6 | import { createMemoryHistory } from "history";
13
14 at Object.<anonymous> (node_modules/@testing-library/react/dist/flush-microtasks.js:28:82)
15 at Object.<anonymous> (node_modules/@testing-library/react/dist/pure.js:52:47)
16 at Object.<anonymous> (node_modules/@testing-library/react/dist/index.js:7:13)
17 at Object.<anonymous> (spec/javascript/support/react-testing-library.js:3:1) |
Are you mocking React somewhere? Any chance to see the jest setup file also? |
I don't think we are mocking React (knowingly). Our setup file is just: import "jest-prop-type-error";
import ReactModal from "react-modal";
ReactModal.setAppElement(document.body);
window.alert = () => {}; |
we just ran into the same issue when upgrading from 9.1.4 to 10.4.4 |
Could someone make a reproduction here? It's much easier to determine the problem with a minimal reproduction. https://kcd.im/rtl-help |
Yeah, I did try to make a minimal reproduction quickly but couldn't unfortunately 😞 I imagine it will involve taking my current config and rebuilding it piece by piece until the error occurs. I'll try to do this when I have the time, but since we are using this in production we are content with simply holding off bumping the version for now. Thanks for all the time you've put in so far @MatanBobi! I'll comment again when I've got a reproduction. |
same for us, breaks after upgrading |
@urlaubsbaron, @adamransom can one of you please attach your Webpack config? |
Here you go: https://pastebin.com/2s7t6Kup We use rails/webpacker so the config is auto-generated and might look a bit funky, not sure! |
@MatanBobi |
thanks @michael5891, If you'll be able to provide a reproduction repo it would really help (https://kcd.im/rtl-help). @adamransom - I saw that in your jest configs you have:
This is a long-shot but I was able to reproduce this on my local env and when I removed the empty string at the bottom this one was fixed. |
It does indeed fix it! For some reason, we used Anyways, problem resolved for us, so thank you for helping! |
looks like we had a similar problem, just in our case it was
changing this to
Thank you everyone! |
@urlaubsbaron, @michael5891 can you please have a look if you have the same jest config by any chance so we'll be able to close this one? |
Same applies for us:
I will replace it with
thanks for clarification |
This should be resolved with #744 which was published a few hours ago. |
@testing-library/react
version: 10.4.4What you did:
Running any test that uses
@testing-library/react
fails withTypeError: Cannot read property 'version' of undefined
that previously used to run fine on 10.4.3.I imagine it's due to the version check in the latest version, but I can't figure out if it is something that I need to change about my config to get it working again? I have a very standard setup I believe and use the library as such:
The text was updated successfully, but these errors were encountered: