'Reactjs Jest - Test cases are passing, Test Suites are failing
recently we tried to update react-markdown package to latest version. after update we ran the unit test cases, all test cases are passing, but some test suites are failing. here is message,
""" Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do: • 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/en/configuration.html
Details:
C:\XXX\Frontend\node_modules\react-markdown\index.js:6 export {uriTransformer} from './lib/uri-transformer.js' ^^^^^^
SyntaxError: Unexpected token 'export'
3 | import React, { useState, useEffect, useContext } from "react"; 4 | import styled from "styled-components";
5 | import ReactMarkdown from "react-markdown"; | ^ 6 | import remarkGfm from 'remark-gfm' 7 | import "react-mde/lib/styles/css/react-mde-all.css";
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/node_modules/@jest/transform/build/ScriptTransformer.js:537:17) at Object. (src/widgets/MarkdownEditor/MarkdownEditor.tsx:5:1)
Test Suites: 7 failed, 93 passed, 100 total Tests: 169 passed, 169 total Snapshots: 0 total Time: 49.308s Ran all test suites. """
these are the jest versions using in package.json
"@testing-library/jest-dom": "^5.16.4", "@types/jest": "^27.4.1", "jest": "^24.9.0",
Thanks for your time.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
