Skip to content

Commit c938f4c

Browse files
authored
replace snapshot tests with react-testing-library (#92)
1 parent a1b58ad commit c938f4c

File tree

6 files changed

+33
-53
lines changed

6 files changed

+33
-53
lines changed

{{cookiecutter.project_slug}}/frontend/package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@testing-library/jest-dom": "^5.7.0",
7-
"@testing-library/user-event": "^12.0.11",
8-
"@types/jest": "^26.0.3",
9-
"@types/node": "^14.0.1",
10-
"@types/react": "^16.9.19",
11-
"@types/react-dom": "^16.9.5",
12-
"@types/react-router-dom": "^5.1.3",
13-
"@types/jwt-decode": "^2.2.1",
146
"ra-data-json-server": "^3.5.2",
157
"ra-data-simple-rest": "^3.3.2",
168
"react": "^16.13.1",
@@ -20,14 +12,13 @@
2012
"react-scripts": "3.4.1",
2113
"react-truncate": "^2.4.0",
2214
"standard": "^14.3.3",
23-
"typescript": "^3.7.5",
2415
"jwt-decode": "^2.2.0",
2516
"@material-ui/lab": "^4.0.0-alpha.54"
2617
},
2718
"scripts": {
2819
"start": "react-scripts start",
2920
"build": "react-scripts build",
30-
"test": "CI=true react-scripts test --env=jsdom -u",
21+
"test": "CI=true react-scripts test",
3122
"eject": "react-scripts eject"
3223
},
3324
"eslintConfig": {
@@ -46,9 +37,18 @@
4637
]
4738
},
4839
"devDependencies": {
40+
"typescript": "^3.7.5",
41+
"@testing-library/jest-dom": "^5.11.1",
4942
"@testing-library/react": "^10.0.4",
5043
"@typescript-eslint/eslint-plugin": "^2.24.0",
5144
"@typescript-eslint/parser": "^2.24.0",
45+
"@testing-library/user-event": "^12.0.11",
46+
"@types/jest": "^26.0.3",
47+
"@types/node": "^14.0.1",
48+
"@types/react": "^16.9.19",
49+
"@types/react-dom": "^16.9.5",
50+
"@types/react-router-dom": "^5.1.3",
51+
"@types/jwt-decode": "^2.2.1",
5252
"eslint-config-airbnb": "^18.1.0",
5353
"eslint-config-react-app": "^5.2.1",
5454
"eslint-plugin-flowtype": "^4.6.0",

{{cookiecutter.project_slug}}/frontend/src/__tests__/__snapshots__/home-test.tsx.snap

-27
This file was deleted.

{{cookiecutter.project_slug}}/frontend/src/__tests__/home-test.tsx

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import '@testing-library/jest-dom/extend-expect';
4+
import { Home } from '../views/Home';
5+
6+
it('Home renders correctly', () => {
7+
const home = render(<Home />);
8+
expect(home.getByText('Admin Dashboard')).toBeInTheDocument();
9+
expect(home.getByText('Protected Route')).toBeInTheDocument();
10+
expect(home.getByText('Login')).toBeInTheDocument();
11+
expect(home.getByText('Sign Up')).toBeInTheDocument();
12+
});

{{cookiecutter.project_slug}}/frontend/src/__tests__/login-test.tsx

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import '@testing-library/jest-dom/extend-expect';
4+
import { Login } from '../views';
5+
6+
it('Login renders correctly', () => {
7+
const login = render(<Login />);
8+
expect(login.getByText('Email')).toBeInTheDocument();
9+
expect(login.getByText('Password')).toBeInTheDocument();
10+
expect(login.getByText('Login')).toBeInTheDocument();
11+
});

0 commit comments

Comments
 (0)