Files
next.js/test/production/pnpm-support/index.test.ts
Arian Tron 61f56f997c
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
first commit
2026-03-10 19:37:31 +03:30

136 lines
3.5 KiB
TypeScript

/* eslint-env jest */
import path from 'path'
import fs from 'fs-extra'
import webdriver from 'next-webdriver'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import {
findPort,
initNextServerScript,
killApp,
renderViaHTTP,
} from 'next-test-utils'
describe('pnpm support', () => {
let next: NextInstance | undefined
afterEach(async () => {
try {
await next?.destroy()
} catch (_) {}
})
it('should build with dependencies installed via pnpm', async () => {
next = await createNext({
files: {
pages: new FileRef(path.join(__dirname, 'app/pages')),
'next.config.js': new FileRef(
path.join(__dirname, 'app/next.config.js')
),
},
packageJson: {
scripts: {
build: 'next build',
start: 'next start',
},
},
buildCommand: 'pnpm run build',
})
expect(await next.readFile('pnpm-lock.yaml')).toBeTruthy()
expect(next.cliOutput).toMatch(/Compiled successfully/)
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('Hello World')
const manifest = JSON.parse(
await next.readFile('.next/next-server.js.nft.json')
)
for (const ignore of ['next/dist/pages', '.wasm', 'compiled/@ampproject']) {
let matchingFile
try {
matchingFile = manifest.files.some((file) => file.includes(ignore))
expect(!!matchingFile).toBe(false)
} catch (err) {
require('console').error(
`Found unexpected file in manifest ${matchingFile} matched ${ignore}`
)
throw err
}
}
})
it('should execute client-side JS on each page in output: "standalone"', async () => {
next = await createNext({
files: {
pages: new FileRef(path.join(__dirname, 'app-multi-page/pages')),
'.npmrc': new FileRef(path.join(__dirname, 'app-multi-page/.npmrc')),
'next.config.js': new FileRef(
path.join(__dirname, 'app-multi-page/next.config.js')
),
},
packageJson: {
scripts: {
dev: 'next dev',
build: 'next build',
start: 'next start',
},
},
buildCommand: 'pnpm run build',
})
await next.stop()
expect(next.cliOutput).toMatch(/Compiled successfully/)
let appPort
let server
let browser
try {
appPort = await findPort()
const standaloneDir = path.join(
next.testDir,
'.next/standalone/',
path.basename(next.testDir)
)
// simulate what happens in a Dockerfile
await fs.remove(path.join(next.testDir, 'node_modules'))
await fs.copy(
path.join(next.testDir, './.next/static'),
path.join(standaloneDir, './.next/static'),
{ overwrite: true }
)
server = await initNextServerScript(
path.join(standaloneDir, 'server.js'),
/- Local:/,
{
...process.env,
PORT: appPort,
},
undefined,
{
cwd: standaloneDir,
}
)
await renderViaHTTP(appPort, '/')
browser = await webdriver(appPort, '/', {
waitHydration: false,
})
expect(await browser.waitForElementByCss('#world').text()).toBe('World')
await browser.close()
browser = await webdriver(appPort, '/about', {
waitHydration: false,
})
expect(await browser.waitForElementByCss('#world').text()).toBe('World')
await browser.close()
} finally {
if (server) {
await killApp(server)
}
}
})
})