Skip to content

Commit 41fa29d

Browse files
committed
Add tests
1 parent baa1224 commit 41fa29d

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

test/integration/cli/test/index.test.js

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
/* eslint-env jest */
22

3-
import { runNextCommand, runNextCommandDev, findPort } from 'next-test-utils'
4-
import { join } from 'path'
3+
import {
4+
findPort,
5+
killApp,
6+
launchApp,
7+
runNextCommand,
8+
runNextCommandDev,
9+
} from 'next-test-utils'
510
import pkg from 'next/package'
11+
import { join } from 'path'
612
jest.setTimeout(1000 * 60 * 5)
713

814
const dir = join(__dirname, '..')
15+
const dirOldReact = join(__dirname, '../old-react')
16+
const dirOldReactDom = join(__dirname, '../old-react-dom')
917

1018
describe('CLI Usage', () => {
1119
describe('no command', () => {
@@ -176,6 +184,44 @@ describe('CLI Usage', () => {
176184
})
177185
expect(stderr).not.toContain('UnhandledPromiseRejectionWarning')
178186
})
187+
188+
test('too old of react version', async () => {
189+
const port = await findPort()
190+
191+
let stderr = ''
192+
let instance = await launchApp(dirOldReact, port, {
193+
stderr: true,
194+
onStderr(msg) {
195+
stderr += msg
196+
},
197+
})
198+
199+
expect(stderr).toMatch(
200+
'Fast Refresh is disabled in your application due to an outdated `react` version'
201+
)
202+
expect(stderr).not.toMatch(`react-dom`)
203+
204+
await killApp(instance)
205+
})
206+
207+
test('too old of react-dom version', async () => {
208+
const port = await findPort()
209+
210+
let stderr = ''
211+
let instance = await launchApp(dirOldReactDom, port, {
212+
stderr: true,
213+
onStderr(msg) {
214+
stderr += msg
215+
},
216+
})
217+
218+
expect(stderr).toMatch(
219+
'Fast Refresh is disabled in your application due to an outdated `react-dom` version'
220+
)
221+
expect(stderr).not.toMatch('`react`')
222+
223+
await killApp(instance)
224+
})
179225
})
180226

181227
describe('export', () => {

0 commit comments

Comments
 (0)