From 5a46b25137e1f00de27f3b00a7fa26a13d95ccd4 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Thu, 10 Jul 2025 10:22:50 +0200 Subject: [PATCH] test: add next version constraint for turbopack fixture and test --- .../hello-world-turbopack/package.json | 5 ++++ .../integration/hello-world-turbopack.test.ts | 25 +++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/fixtures/hello-world-turbopack/package.json b/tests/fixtures/hello-world-turbopack/package.json index b2341d6260..eccf26b6c7 100644 --- a/tests/fixtures/hello-world-turbopack/package.json +++ b/tests/fixtures/hello-world-turbopack/package.json @@ -11,5 +11,10 @@ "next": "latest", "react": "18.2.0", "react-dom": "18.2.0" + }, + "test": { + "dependencies": { + "next": ">=15.3.0-canary.43" + } } } diff --git a/tests/integration/hello-world-turbopack.test.ts b/tests/integration/hello-world-turbopack.test.ts index dd681433b6..803a714b54 100644 --- a/tests/integration/hello-world-turbopack.test.ts +++ b/tests/integration/hello-world-turbopack.test.ts @@ -1,13 +1,13 @@ import { load } from 'cheerio' import { getLogger } from 'lambda-local' -import { cp } from 'node:fs/promises' import { HttpResponse, http, passthrough } from 'msw' import { setupServer } from 'msw/node' import { v4 } from 'uuid' -import { Mock, afterAll, afterEach, beforeAll, beforeEach, expect, test, vi } from 'vitest' +import { afterAll, afterEach, beforeAll, beforeEach, expect, test, vi } from 'vitest' import { type FixtureTestContext } from '../utils/contexts.js' import { createFixture, invokeFunction, runPlugin } from '../utils/fixture.js' import { generateRandomObjectID, startMockBlobStore } from '../utils/helpers.js' +import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs' vi.mock('node:fs/promises', async (importOriginal) => { const fsPromisesModule = (await importOriginal()) as typeof import('node:fs/promises') @@ -61,12 +61,17 @@ afterEach(() => { vi.unstubAllEnvs() }) -test('Test that the hello-world-turbopack next app is working', async (ctx) => { - await createFixture('hello-world-turbopack', ctx) - await runPlugin(ctx) +// https://github.com/vercel/next.js/pull/77808 makes turbopack builds no longer gated only to canaries +// allowing to run this test on both stable and canary versions of Next.js +test.skipIf(!nextVersionSatisfies('>=15.3.0-canary.43'))( + 'Test that the hello-world-turbopack next app is working', + async (ctx) => { + await createFixture('hello-world-turbopack', ctx) + await runPlugin(ctx) - // test the function call - const home = await invokeFunction(ctx) - expect(home.statusCode).toBe(200) - expect(load(home.body)('h1').text()).toBe('Hello, Next.js!') -}) + // test the function call + const home = await invokeFunction(ctx) + expect(home.statusCode).toBe(200) + expect(load(home.body)('h1').text()).toBe('Hello, Next.js!') + }, +)