-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Docs: Correct JavaScript React Component File Extension to .jsx in '01-vitest.mdx' #61087
Conversation
@sogoagain The config file isn't a React component → https://vitest.dev/config/#configuration (all the examples are using |
b35b966
to
02f1d24
Compare
@samcx Oops, sorry. I should have edited the |
@sogoagain Thank you for the update! Although I would agree using |
@samcx Yes, I agree it's fine to use the But the problem is, when I try to configure the vitest environment using next.js in Javascript, if I follow the documentation, I get an error when running the test due to the In fact, in the Typescript example code, it is written as |
@sogoagain Can you share the error as well and your Vite versions? This may be solely a Vite thing, which if true, it may be best to just switch this to |
Sure. The error details are as follows. FAIL __tests__/page.test.jsx [ __tests__/page.test.jsx ]
Error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
❯ formatError node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63768:46
❯ TransformContext.error node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63762:19
❯ TransformContext.transform node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:61979:22
❯ Object.transform node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64063:30
❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:49741:29 The version of Thank you. |
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
This PR resolves a file extension inconsistency in the 'Setting up Vitest with Next.js' section of the Next.js documentation (
01-vitest.mdx
).When using next.js with JavaScript, following the documentation(
01-vitest.mdx
) leads to issues during testing because of the jsx extension.This PR corrects an example code that wrongly uses a '.js' extension for a React component, which is against Vitest's requirement for '.jsx' extensions.
Thank you.