-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[0.20.2]: Tets fails if importing tslib
#1753
Comments
I'm seeing a similar error after upgrading to vitest^0.20 when using SyntaxError: Named export 'createEvent' not found. The requested module '@testing-library/dom' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@testing-library/dom';
const { createEvent: createEventBase } = pkg; |
I'm experiencing a similar issue in the latest version(0.20.2), on some very basic tests |
Looks like tslib is not following the ESM standard correctly, and guessing it's the same issue with other packages. 😑 |
Setting deps.registerNodeLoader to |
Yes, for now you can opt-out of this behaviour with |
Please, create a reproduction, if the issue doesn't involve tslib. |
Getting similar issue with CJS export. In my case it's with one of cheerio packages's dep. SyntaxError: Named export 'AttributeAction' not found. The requested module 'css-what' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'css-what';
const { AttributeAction, SelectorType } = pkg; Reproduction: https://github.com/ggowtham67/vitest-v0.20.2-cjs-broken-export-repro Edit: Solution suggested by @thebuilder works <3
|
Getting this as well
|
Upgrading vitest to v0.21.0 now solves the issue.
/** @type {import('vite').UserConfig} */
export default {
test: {
- registerNodeLoader: false,
},
}; |
Technically this PR should also work with |
Describe the bug
After upgrading to v0.20.x, most of my tests are now failing with:
It's caused by framer-motion using tslib. The package does include an exports field and module support, so a bit weird why this is popping up. Thinking it's related to how node modules are resolved now after #1673.
Reproduction
The issue can be replicated by importing
<framer-motion>
in a test file.https://stackblitz.com/edit/vitest-dev-vitest-ue9bu2?file=test/App.test.tsx
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: