Jest
Jest is a delightful JavaScript Testing Framework with a focus on simplicity.
How to use
Snapshot Testing Example
import React from 'react';
import renderer from 'react-test-renderer';
import Link from '../Link.react';
it('renders correctly', () => {
const tree = renderer
.create(<Link page="http://www.facebook.com">Facebook</Link>)
.toJSON();
expect(tree).toMatchSnapshot();
});Unit Testing Example
import React from "react";
import Section from "@/page/section";
it("should show Hello World", () => {
render(<Section />);
const element = screen.getByTestId(`hello-world`);
expect(element.textContent).toContain("Hello World");
});Testing a Component with Redux Store
Handle Next.js Dynamic Import
Last updated