-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathdeploy.test.ts
109 lines (97 loc) · 3.63 KB
/
deploy.test.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { afterEach, describe, expect, test } from 'vitest'
import { Fixture, fixtureFactories } from '../utils/create-e2e-fixture'
const usedFixtures = new Set<Fixture>()
/**
* When fixture is used, it is automatically cleanup after test finishes
*/
const selfCleaningFixtureFactories = new Proxy(fixtureFactories, {
get(target, prop) {
return async () => {
const val = target[prop]
if (typeof val === 'function') {
const fixture = await val()
usedFixtures.add(fixture)
return fixture
}
return val
}
},
})
afterEach(async () => {
for (const fixture of usedFixtures) {
await fixture.cleanup()
}
usedFixtures.clear()
})
async function smokeTest(createFixture: () => Promise<Fixture>) {
const fixture = await createFixture()
const response = await fetch(fixture.url)
expect(response.status).toBe(200)
// remove comments that React injects into produced html
const body = (await response.text()).replace(/<!--.+-->/g, '')
await expect(body).toContain('SSR: yes')
}
test('yarn@3 monorepo with pnpm linker', async () => {
await smokeTest(selfCleaningFixtureFactories.yarnMonorepoWithPnpmLinker)
})
test('npm monorepo deploying from site directory without --filter', async () => {
await smokeTest(selfCleaningFixtureFactories.npmMonorepoEmptyBaseNoPackagePath)
})
test('npm monorepo creating site workspace as part of build step (no packagePath set)', async () => {
await smokeTest(selfCleaningFixtureFactories.npmMonorepoSiteCreatedAtBuild)
})
describe('version check', () => {
test(
'[email protected] (first version building on recent node versions) should not deploy',
{ retry: 0 },
async () => {
// we are not able to get far enough to extract concrete next version, so this error message lack used Next.js version
await expect(selfCleaningFixtureFactories.next12_0_3()).rejects.toThrow(
/Your publish directory does not contain expected Next.js build output. Please make sure you are using Next.js version \(>=13.5.0\)/,
)
},
)
test(
'[email protected] (first version with standalone output supported) should not deploy',
{ retry: 0 },
async () => {
await expect(selfCleaningFixtureFactories.next12_1_0()).rejects.toThrow(
new RegExp(
`@netlify/plugin-nextjs@5 requires Next.js version >=13.5.0, but found 12.1.0. Please upgrade your project's Next.js version.`,
),
)
},
)
test('yarn monorepo multiple next versions site is compatible', { retry: 0 }, async () => {
await smokeTest(selfCleaningFixtureFactories.yarnMonorepoMultipleNextVersionsSiteCompatible)
})
test(
'yarn monorepo multiple next versions site is incompatible should not deploy',
{ retry: 0 },
async () => {
await expect(
selfCleaningFixtureFactories.yarnMonorepoMultipleNextVersionsSiteIncompatible(),
).rejects.toThrow(
new RegExp(
`@netlify/plugin-nextjs@5 requires Next.js version >=13.5.0, but found 13.4.1. Please upgrade your project's Next.js version.`,
),
)
},
)
test('npm nested site multiple next versions site is compatible', async () => {
await smokeTest(fixtureFactories.npmNestedSiteMultipleNextVersionsCompatible)
})
test(
'npm nested site multiple next versions site is incompatible should not deploy',
{ retry: 0 },
async () => {
await expect(
fixtureFactories.npmNestedSiteMultipleNextVersionsIncompatible(),
).rejects.toThrow(
new RegExp(
`@netlify/plugin-nextjs@5 requires Next.js version >=13.5.0, but found 13.4.1. Please upgrade your project's Next.js version.`,
),
)
},
)
})