plone / training

Plone Trainings
https://training.plone.org
Creative Commons Attribution 4.0 International
56 stars 89 forks source link

Issue on page /react/snapshot_testing.html [7. Use Snapshot Testing] #590

Open avimishra18 opened 2 years ago

avimishra18 commented 2 years ago

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

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();
    });
});
stevepiercy commented 2 years ago

Please submit a PR for this, but use spaces instead of tabs.