-
Notifications
You must be signed in to change notification settings - Fork 27.5k
/
Copy pathindex.test.js
62 lines (55 loc) · 1.54 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* eslint-env jest */
import { join } from 'path'
import { execSync } from 'child_process'
import {
findPort,
killApp,
launchApp,
nextBuild,
nextStart,
renderViaHTTP,
} from 'next-test-utils'
let app
let appPort
const appDir = join(__dirname, '../')
const runTests = () => {
it('should resolve index page correctly', async () => {
const html = await renderViaHTTP(appPort, '/')
expect(html).toContain('Hello, World!')
})
}
const runRelayCompiler = () => {
// Relay expects the current directory to contain a relay.json
// This ensures the CWD is the one with relay.json since running
// the relay-compiler through pnpm would make the root of the repo the CWD.
execSync('../../../node_modules/relay-compiler/cli.js', {
cwd: './test/integration/relay-graphql-swc-single-project',
})
}
describe('Relay Compiler Transform - Single Project Config', () => {
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
runRelayCompiler()
appPort = await findPort()
app = await launchApp(appDir, appPort, { cwd: appDir })
})
afterAll(() => killApp(app))
runTests()
}
)
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
runRelayCompiler()
await nextBuild(appDir, [], { cwd: appDir })
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
}
)
})