Skip to content

Instantly share code, notes, and snippets.

@CodeNinja47
Created January 19, 2023 09:56
Show Gist options
  • Save CodeNinja47/5cde736cb461193db361755f2531669b to your computer and use it in GitHub Desktop.
Save CodeNinja47/5cde736cb461193db361755f2531669b to your computer and use it in GitHub Desktop.
import React from "react";
import { render } from "@testing-library/react";
import SampleComponent from "./SampleComponent";
import { SampleComponentProps } from "./SampleComponent.types";
describe("Sample Component", () => {
let props: SampleComponentProps;
beforeEach(() => {
props = {
text: "sample"
};
});
it("should have text as sample", () => {
const { getByTestId } = render(<SampleComponent {...props} />)
const testComponent = getByTestId("sample-text");
expect(testComponent).toHaveTextContent("sample");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment