training icon indicating copy to clipboard operation
training copied to clipboard

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

Open avimishra18 opened this issue 3 years ago • 1 comments

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();
	});
});

avimishra18 avatar Mar 12 '22 07:03 avimishra18

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

stevepiercy avatar Mar 12 '22 07:03 stevepiercy