Skip to content

Commit c56acc8

Browse files
committed
refactor: migrate to Create React App v5
1 parent 6edcbe7 commit c56acc8

File tree

5 files changed

+28
-153
lines changed

5 files changed

+28
-153
lines changed

src/App.test.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import React from 'react'
2-
import { shallow } from 'enzyme/build'
2+
import { render, screen } from '@testing-library/react'
33
import App from './App'
4-
import Dashboard from './views/dashboard/Dashboard.js'
54

6-
it('mounts App without crashing', () => {
7-
const wrapper = shallow(<App />)
8-
wrapper.unmount()
9-
})
10-
11-
it('mounts Dashboard without crashing', () => {
12-
const wrapper = shallow(<Dashboard />)
13-
wrapper.unmount()
5+
test('renders learn react link', () => {
6+
render(<App />)
7+
const linkElement = screen.getByText(/learn react/i)
8+
expect(linkElement).toBeInTheDocument()
149
})

src/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'core-js'
33
import React from 'react'
44
import ReactDOM from 'react-dom'
55
import App from './App'
6-
import * as serviceWorker from './serviceWorker'
6+
import reportWebVitals from './reportWebVitals'
77
import { Provider } from 'react-redux'
88
import store from './store'
99

@@ -14,7 +14,7 @@ ReactDOM.render(
1414
document.getElementById('root'),
1515
)
1616

17-
// If you want your app to work offline and load faster, you can change
18-
// unregister() to register() below. Note this comes with some pitfalls.
19-
// Learn more about service workers: http://bit.ly/CRA-PWA
20-
serviceWorker.unregister()
17+
// If you want to start measuring performance in your app, pass a function
18+
// to log results (for example: reportWebVitals(console.log))
19+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20+
reportWebVitals()

src/reportWebVitals.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const reportWebVitals = (onPerfEntry) => {
2+
if (onPerfEntry && onPerfEntry instanceof Function) {
3+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4+
getCLS(onPerfEntry)
5+
getFID(onPerfEntry)
6+
getFCP(onPerfEntry)
7+
getLCP(onPerfEntry)
8+
getTTFB(onPerfEntry)
9+
})
10+
}
11+
}
12+
13+
export default reportWebVitals

src/serviceWorker.js

-123
This file was deleted.

src/setupTests.js

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
import { configure } from 'enzyme'
2-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'
3-
4-
configure({ adapter: new Adapter() })
5-
6-
if (global.document) {
7-
document.createRange = () => ({
8-
setStart: () => {},
9-
setEnd: () => {},
10-
commonAncestorContainer: {
11-
nodeName: 'BODY',
12-
ownerDocument: document,
13-
},
14-
})
15-
}
1+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
2+
// allows you to do things like:
3+
// expect(element).toHaveTextContent(/react/i)
4+
// learn more: https://github.com/testing-library/jest-dom
5+
import '@testing-library/jest-dom'

0 commit comments

Comments
 (0)