1"jest": {
2 "setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js",
3 "testPathIgnorePatterns": [
4 "<rootDir>/.next/",
5 "<rootDir>/node_modules/"
6 ],
7 "transform": {
8 "\\.(gql|graphql)$": "jest-transform-graphql",
9 ".*": "babel-jest",
10 "^.+\\.js?$": "babel-jest"
11 },
12 "moduleFileExtensions": [
13 "js",
14 "json",
15 "ts",
16 "tsx"
17 ],
18 "modulePaths": [
19 "<rootDir>/components/",
20 "<rootDir>/pages/",
21 "<rootDir>/shared/"
22 ]
23}
1import React from 'react';
2import { shallow } from 'enzyme';
3import toJson from 'enzyme-to-json';
4
5// @ts-ignore (works with .tsx)
6import Astronaut from '../Astronaut.tsx';
7
8describe('<Astronaut /> component', () => {
9 describe('should render', () => {
10 const wrapper = shallow(<Astronaut showLogo={true} />);
11 it ('should render a component matching the snapshot', () => {
12 const tree = toJson(wrapper);
13 expect(tree).toMatchSnapshot();
14 expect(wrapper).toHaveLength(1);
15 });
16 });
17});