Skip to content

Commit 7310c60

Browse files
committed
chore: cleanup tests, upgrade deps
1 parent d179afe commit 7310c60

File tree

5 files changed

+384
-286
lines changed

5 files changed

+384
-286
lines changed

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"devDependencies": {
2626
"babel-cli": "^6.7.5",
2727
"babel-core": "^6.7.6",
28-
"babel-eslint": "^8.1.2",
29-
"babel-jest": "^22.0.4",
28+
"babel-eslint": "^8.2.1",
29+
"babel-jest": "^22.1.0",
3030
"babel-plugin-dynamic-import-node": "^1.2.0",
3131
"babel-plugin-transform-class-properties": "^6.24.1",
3232
"babel-plugin-transform-object-rest-spread": "^6.26.0",
@@ -38,22 +38,22 @@
3838
"conventional-github-releaser": "^2.0.0",
3939
"create-react-class": "^15.6.2",
4040
"cross-env": "^5.1.3",
41-
"enzyme": "^3.1.0",
41+
"enzyme": "^3.3.0",
4242
"enzyme-adapter-react-15": "^1.0.5",
4343
"enzyme-adapter-react-16": "^1.1.1",
44-
"eslint": "^4.14.0",
44+
"eslint": "^4.16.0",
4545
"eslint-config-airbnb": "^16.0.0",
4646
"eslint-config-prettier": "^2.6.0",
4747
"eslint-plugin-import": "^2.7.0",
4848
"eslint-plugin-jsx-a11y": "^6.0.3",
4949
"eslint-plugin-react": "^7.4.0",
5050
"husky": "^0.14.3",
51-
"jest": "^22.0.4",
52-
"lerna": "^2.4.0",
51+
"jest": "^22.1.4",
52+
"lerna": "^2.8.0",
5353
"lerna-tools": "^1.0.0",
54-
"lint-staged": "^6.0.0",
54+
"lint-staged": "^6.0.1",
5555
"mocha": "^4.0.1",
56-
"prettier": "^1.9.2",
56+
"prettier": "^1.10.2",
5757
"react": "16",
5858
"react-dom": "16",
5959
"react-mount": "^0.1.3",

packages/react-hot-loader/src/AppContainer.dev.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3+
import logger from './logger'
34
import { get as getGeneration } from './global/generation'
45
import getReactStack from './internal/getReactStack'
56
import hotReplacementRender from './reconciler/hotReplacementRender'
@@ -41,17 +42,15 @@ class AppContainer extends React.Component {
4142
}
4243

4344
componentDidCatch(error) {
45+
logger.error(error)
4446
this.setState({ error })
4547
}
4648

4749
render() {
4850
const { error } = this.state
4951

5052
if (this.props.errorReporter && error) {
51-
console.error(error)
5253
return <this.props.errorReporter error={error} />
53-
} else if (error) {
54-
console.error(error)
5554
}
5655

5756
return React.Children.only(this.props.children)

packages/react-hot-loader/test/reconciler.test.js

+33-23
Original file line numberDiff line numberDiff line change
@@ -231,35 +231,45 @@ describe('reconciler', () => {
231231
expect(wrapper.text()).toContain(43)
232232
})
233233

234-
it('should handle error on render', () => {
235-
const App = () => <div>Normal application</div>
236-
reactHotLoader.register(App, 'App', 'test.js')
234+
describe('when an error occurs in render', () => {
235+
beforeEach(() => {
236+
jest.spyOn(console, 'error').mockImplementation(() => {})
237+
})
237238

238-
const TestCase = props => (
239-
<AppContainer>
240-
<App {...props} />
241-
</AppContainer>
242-
)
239+
afterEach(() => {
240+
console.error.mockRestore()
241+
})
243242

244-
const wrapper = mount(<TestCase />)
243+
it('should catch error', () => {
244+
const App = () => <div>Normal application</div>
245+
reactHotLoader.register(App, 'App', 'test.js')
245246

246-
{
247-
const App = ({ update = '42' }) => (
248-
<div>
249-
Normal application{' '}
250-
<span>{update ? update.not.existing : '42'}</span>
251-
</div>
247+
const TestCase = () => (
248+
<AppContainer>
249+
<App active />
250+
</AppContainer>
252251
)
253-
reactHotLoader.register(App, 'App', 'test.js')
254252

255-
expect(() => wrapper.setProps({ children: <App /> })).toThrow()
256-
expect(reactHotLoader.disableProxyCreation).toBe(false)
257-
}
253+
const wrapper = mount(<TestCase />)
258254

259-
expect(logger.warn).toHaveBeenCalledWith(
260-
`React-hot-loader: reconcilation failed due to error`,
261-
expect.any(Error),
262-
)
255+
{
256+
const App = ({ active }) => (
257+
<div>
258+
Normal application
259+
<span>{active ? active.not.existing : null}</span>
260+
</div>
261+
)
262+
reactHotLoader.register(App, 'App', 'test.js')
263+
264+
expect(() => wrapper.setProps({ children: <App /> })).toThrow()
265+
expect(reactHotLoader.disableProxyCreation).toBe(false)
266+
}
267+
268+
expect(logger.warn).toHaveBeenCalledWith(
269+
`React-hot-loader: reconcilation failed due to error`,
270+
expect.any(Error),
271+
)
272+
})
263273
})
264274
})
265275
})

packages/react-stand-in/test/lifecycle-method.test.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
/* eslint-env jest */
22
import React, { Component } from 'react'
33
import { createMounter } from './helper'
4-
import createProxy from '../lib'
4+
import createProxy, { setConfig } from '../lib'
5+
6+
setConfig({
7+
logger: {
8+
warn: jest.fn(),
9+
},
10+
})
511

612
describe('lifecycle method', () => {
713
const { mount } = createMounter()

0 commit comments

Comments
 (0)