You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that This is a Markdown paragraph get rendered
Run npm run test
Notice that jest fail forsrc/__tests__/pages/StartPage.test.tsx and src/components/__tests__/PageContent.test.tsx
Current vs. Expected behavior
I would expect that I can write unit tests with packages that get transpiled instead I am getting the error:
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
/Users/weyert/Development/Projects/Reproductions/markdown-jest-next/node_modules/vfile/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export {VFile} from './lib/index.js'
^^^^^^
SyntaxError: Unexpected token 'export'
Verify canary release
I verified that the issue exists in the latest Next.js canary release
Which area(s) are affected? (Select all that apply)
Jest (next/jest)
Additional context
I made a reproduction repository (see above) for an problem I am experiencing in a work project that uses an older version of Next.js (13.4.12) but planning to upgrade to 13.4.20 once its released to solve my modularize import issue from a previous ticket.
I am trying to write unit tests for components that consume the react-markdown package but fail to do so
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
Link to the code that reproduces this issue or a replay of the bug
https://github.com/weyert/nextjs-jest-markdown
To Reproduce
npm run dev
http://127.0.0.1:3000
This is a Markdown paragraph
get renderednpm run test
src/__tests__/pages/StartPage.test.tsx
andsrc/components/__tests__/PageContent.test.tsx
Current vs. Expected behavior
I would expect that I can write unit tests with packages that get transpiled instead I am getting the error:
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 Binaries: Node: 18.14.0 npm: 8.19.3 Yarn: 1.22.19 pnpm: 8.7.3 Relevant Packages: next: 13.4.20-canary.18 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 4.9.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Jest (next/jest)
Additional context
I made a reproduction repository (see above) for an problem I am experiencing in a work project that uses an older version of Next.js (13.4.12) but planning to upgrade to 13.4.20 once its released to solve my modularize import issue from a previous ticket.
I am trying to write unit tests for components that consume the
react-markdown
package but fail to do soThe text was updated successfully, but these errors were encountered: