import React from "react";
import { render } from "@testing-library/react";
import FaqItem from "./FaqItem";
describe("FaqItem", () => {
it("renders a FAQ item", () => {
const component = render(
<FaqItem
question="What is the answer to life the universe and everything?"
answer="42"
/>
);
expect(component).toMatchSnapshot();
});
});
Corrected Code Snippet
import React from "react";
import { render } from "@testing-library/react";
import FaqItem from "./FaqItem";
describe("FaqItem", () => {
it("renders a FAQ item", () => {
const view = render(
<FaqItem
question="What is the answer to life the universe and everything?"
answer="42"
/>
);
expect(view).toMatchSnapshot();
});
});
Issue
ESLint Error: eslint(testing-library/render-result-naming-convention) in the code snippet of the topic 7. Use Snapshot Testing
Link to Community Discussion. Assigning this issue to myself.
Incorrect Code Snippet
Corrected Code Snippet