/
index.test.js
48 lines (42 loc) · 1.1 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-env jest */
import { join } from 'path'
import {
renderViaHTTP,
findPort,
launchApp,
nextBuild,
killApp,
} from 'next-test-utils'
jest.setTimeout(1000 * 60 * 2)
const appDir = join(__dirname, '..')
let appPort
let app
let devOutput
describe('svgo-webpack with Image Component', () => {
describe('next build', () => {
it('should not fail to build invalid usage of the Image component', async () => {
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toBeFalsy()
expect(code).toBe(0)
})
})
describe('next dev', () => {
beforeAll(async () => {
devOutput = { stdout: '', stderr: '' }
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStdout: (msg) => {
devOutput.stdout += msg
},
onStderr: (msg) => {
devOutput.stderr += msg
},
})
})
afterAll(() => killApp(app))
it('should print error when invalid Image usage', async () => {
await renderViaHTTP(appPort, '/', {})
expect(devOutput.stderr).toBeFalsy()
})
})
})