the app i'm working on doesn't use CRA , and im trying to add jest and enzyme , i followed the docs here https://jestjs.io/docs/en/tutorial-react and added the usual setupTests.js file , the example tests in the jest docs are working just fine, but after i added enzyme , i keep getting errors related to css and imports
here's a simple test i wrote
import { shallow } from "enzyme"
import Spinner from "./Spinner"
let wrapped
beforeEach(() => {
wrapped = shallow(<Spinner />)
})
it("has a div", () => {
expect(wrapped.find("div").length).toEqual(1)
})
and here's the error
src/components/Spinner/Spinner.test.js
● Test suite failed to run
/home/islam/Synapse/azka-vision-react/node_modules/antd/es/spin/style/css.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import '../../style/index.css';
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
8 | display: "flex",
9 | justifyContent: "center",
> 10 | alignItems: "center",
| ^
11 | height
12 | }
13 | return (
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
at Object.<anonymous> (src/components/Spinner/Spinner.js:10:1)
Aucun commentaire:
Enregistrer un commentaire