Skip to content

Commit 5b75a84

Browse files
authored
test: add next version constraint for turbopack fixture and test (#3000)
1 parent e7bf18f commit 5b75a84

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

tests/fixtures/hello-world-turbopack/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@
1111
"next": "latest",
1212
"react": "18.2.0",
1313
"react-dom": "18.2.0"
14+
},
15+
"test": {
16+
"dependencies": {
17+
"next": ">=15.3.0-canary.43"
18+
}
1419
}
1520
}

tests/integration/hello-world-turbopack.test.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { load } from 'cheerio'
22
import { getLogger } from 'lambda-local'
3-
import { cp } from 'node:fs/promises'
43
import { HttpResponse, http, passthrough } from 'msw'
54
import { setupServer } from 'msw/node'
65
import { v4 } from 'uuid'
7-
import { Mock, afterAll, afterEach, beforeAll, beforeEach, expect, test, vi } from 'vitest'
6+
import { afterAll, afterEach, beforeAll, beforeEach, expect, test, vi } from 'vitest'
87
import { type FixtureTestContext } from '../utils/contexts.js'
98
import { createFixture, invokeFunction, runPlugin } from '../utils/fixture.js'
109
import { generateRandomObjectID, startMockBlobStore } from '../utils/helpers.js'
10+
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
1111

1212
vi.mock('node:fs/promises', async (importOriginal) => {
1313
const fsPromisesModule = (await importOriginal()) as typeof import('node:fs/promises')
@@ -61,12 +61,17 @@ afterEach(() => {
6161
vi.unstubAllEnvs()
6262
})
6363

64-
test<FixtureTestContext>('Test that the hello-world-turbopack next app is working', async (ctx) => {
65-
await createFixture('hello-world-turbopack', ctx)
66-
await runPlugin(ctx)
64+
// https://github.com/vercel/next.js/pull/77808 makes turbopack builds no longer gated only to canaries
65+
// allowing to run this test on both stable and canary versions of Next.js
66+
test.skipIf(!nextVersionSatisfies('>=15.3.0-canary.43'))<FixtureTestContext>(
67+
'Test that the hello-world-turbopack next app is working',
68+
async (ctx) => {
69+
await createFixture('hello-world-turbopack', ctx)
70+
await runPlugin(ctx)
6771

68-
// test the function call
69-
const home = await invokeFunction(ctx)
70-
expect(home.statusCode).toBe(200)
71-
expect(load(home.body)('h1').text()).toBe('Hello, Next.js!')
72-
})
72+
// test the function call
73+
const home = await invokeFunction(ctx)
74+
expect(home.statusCode).toBe(200)
75+
expect(load(home.body)('h1').text()).toBe('Hello, Next.js!')
76+
},
77+
)

0 commit comments

Comments
 (0)