I am completely new to testing in React. All I'm trying to do here is creating a simple test I got from this site . When I import my component IdeaCarousel I get an error. It seems like my test doesn't run at all because of this error. When I googled the error I saw it may have something to do with setting up babel or jest, but I've never done something like that before.
I'm testing my React app with jest.
import React from "react";
import IdeaCarousel from "../components/IdeaCarousel";
describe("IdeaCarousel component", () => {
test("it matches the snapshot", () => {
const component = create(<IdeaCarousel />);
expect(component.toJSON()).toMatchSnapshot();
});
});
The error I get:
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 pla in JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_ modules".
Aucun commentaire:
Enregistrer un commentaire