-
Notifications
You must be signed in to change notification settings - Fork 252
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
_userEvent.default.setup is not a function #839
Comments
Could you please provide a reproduction? |
I am also facing the same issue.
Output: This is my jest and RTL versions: |
@bijay-ps |
What build tools are you using (it would help to see your configs as well)? |
The same thing happened to me. I'm using typescript with jest Node 16 lts. "devDependencies": {
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^14.0.0-beta",
"jest": "^27.5.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.5.0"
} {
"compilerOptions": {
"allowUmdGlobalAccess": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noUnusedParameters": false,
"noUnusedLocals": true,
"skipLibCheck": true,
"moduleResolution": "node",
"removeComments": true,
"target": "ESNEXT",
"module": "ESNext",
"noEmit": true,
"esModuleInterop": true,
"jsx": "react"
},
"include": ["src"]
} export default {
clearMocks: true,
collectCoverage: true,
coverageDirectory: "coverage",
coverageProvider: "v8",
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'jest-environment-jsdom',
transform: {},
transformIgnorePatterns: [
"node_modules/(?!(ts-invariant)/)",
],
extensionsToTreatAsEsm: [
".jsx",
".ts",
".tsx"
],
globals: {
'ts-jest': {
useESM: true
},
},
setupFilesAfterEnv: ['./jest.setup.ts']
};
error: If I run I can access the methods if I access them through |
Strangely enough, this issue is not present on my private CI runner I'm running on EC2. So it seems to be related to my local environment. I'm using |
The import works just fine in node locally and on Stackblitz: @mattxyzeth Could you check if this works in both of your environments outside of the test runner? Also please have a look at this: #757 (comment) |
I'll try to test this out soon. Just a quick note, the stackblitz you posted isn't using typescript. My problem is definitely a configuration issue but I can't seem to figure out what is configured wrong. No matter what I try my import is always coming from the |
Could you create a reproduction please? |
I’ll be busy for a while working on a big release coming up in the next couple of months. I will be happy to help in June. Sorry for not being available sooner.
… On Mar 17, 2022, at 9:01 AM, Tim Deschryver ***@***.***> wrote:
Could you create a reproduction please?
FWIW, the latest version (previous version too) seems to be working in combination with TypeScript in the Angular Testing Library - testing-library/angular-testing-library#283 <testing-library/angular-testing-library#283>
—
Reply to this email directly, view it on GitHub <#839 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAJDA3EAA6EV3N3K3HTASETVAMUJPANCNFSM5MMYUHUA>.
You are receiving this because you were mentioned.
|
-import userEvent from '@testing-library/user-event';
+import * userEvent from '@testing-library/user-event'; |
This is the ESM export by esbuild: 2966 | var userEvent = __spreadProps(__spreadValues({}, directApi_exports), {
2967 | setup: setupMain
2968 | });
2969 | export {
2970 | PointerEventsCheckLevel,
2971 | userEvent as default
2972 | }; |
Oh we're talking about the beta. The latest stable didn't have a ESM entrypoint specified in the package.json so I was confused. Can't say why this is happening in the beta without a repro. |
Could this be related to jestjs/jest#12120? I am running typescript and ts-jest and the import is |
Same issue, but with any of the |
same issue getting jsdom fourteen w/ jest react-scripts
|
Any update on this? |
This happened to me today with What I found was that this happened in my project because the files in the Here's the patch file I created locally:
|
I came across the same issue too.
|
For me works after add:
|
I just had to update to the latest version: |
hello, i have the same problem and i have already tried with version 14 and 13.5.0 of @testing-library/dom/user-event |
Slightly more edge case example. Using the UserEvent library in a |
Also experiencing the same issue (just tried to update to latest), reverting to v13 for the moment until it's solved. |
It seems that the current export - although it shouldn't - does still cause problems in some environments. Would you please check out this
@Tommoore96 |
The alternative build package changed the error to TypeError: target.ownerDocument.createRange is not a function |
I had the same error. @testing-library/user-event version 14.3 Tried this test just to get it up and running:
My error:
This build seems to have solved the error I was getting. I don't want to react to the comment since I'm not any of the people tagged. |
@ramonaspence Thanks for the feedback. I just tagged the people who upvoted the issue or commented that they are affected. I'm happy if someone else is following this conversation and adds a reaction. ;) |
I got same problem, here is my situation:
It's clearly Maybe most problems which package is |
The test currently fails due to a bug in react testing libarary (testing-library/user-event#839). Once this is resolved the test can be activated and should work
* [ui] CodeBlock: add tabbed codeblocks * [ui] CodeBlock: add tests for tabbed codeblock * [ui] Codeblock: remove obsolete, adjust styles * [ui] CodeBlock: add disabled test for copy to clipboard The test currently fails due to a bug in react testing libarary (testing-library/user-event#839). Once this is resolved the test can be activated and should work
🎉 This issue has been resolved in version 14.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I am encountering the same exact issue on 14.4.3. I am trying to install user-event using the install instructions available here and then call To Reproduce Steps to reproduce the behavior:
Expected behavior I expect, on installing Screenshots If applicable, add screenshots to help explain your problem.
Default
Desktop (please complete the following information):
Additional context |
|
This solved it for me, thank you! |
I was having the same issue on 14.4.3 but importing it as follows works:
|
In my case it's even different, it seems that the only following version is working:
FYI I'm using typescript 5.1.6 with |
Here's what worked for me:
These are my dependencies:
|
I had a migration from cjs to esm, userEvent started didn't work anymore. A solution worked well for me is to add this to import userEvent from'@testing-library/user-event';
jest.unstable_mockModule('@testing-library/user-event', () => ({
default: userEvent.default,
})); Then it worked normally without any more changes. |
I was able to solve this problem by updating tsconfig.json I had used @sveltejs/package to create my app, which by default had the following settings:
moduleResolution allows you to "Specify how TypeScript looks up a file from a given module specifier." Changing the above settings to:
Solved the problem |
@testing-library/user-event
version: ^14.0.0-betaRelevant code or config
What you did:
Tests worked perfectly before updating, I just wanted the latest version for the pointer method.
Followed the latest documentation and tried multiple versions 14 and above.
Imported like so:
and initialised like so:
What happened:
Tests failed and receive following error:
TypeError: _userEvent.default.setup is not a function
The text was updated successfully, but these errors were encountered: