Files
next.js/test/e2e/prerender-native-module.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

124 lines
3.7 KiB
TypeScript

import path from 'path'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import webdriver from 'next-webdriver'
const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
describe('prerender native module', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(
path.join(__dirname, 'prerender-native-module/pages')
),
'data.sqlite': new FileRef(
path.join(__dirname, 'prerender-native-module/data.sqlite')
),
},
dependencies: {
sqlite: '4.0.22',
sqlite3: '5.0.2',
},
packageJson: {
pnpm: {
onlyBuiltDependencies: ['sqlite3'],
},
},
})
})
afterAll(() => next.destroy())
it('should render index correctly', async () => {
const browser = await webdriver(next.url, '/')
expect(await browser.elementByCss('#index').text()).toBe('index page')
expect(JSON.parse(await browser.elementByCss('#props').text())).toEqual({
index: true,
})
})
it('should render /blog/first correctly', async () => {
const browser = await webdriver(next.url, '/blog/first')
expect(await browser.elementByCss('#blog').text()).toBe('blog page')
expect(JSON.parse(await browser.elementByCss('#props').text())).toEqual({
params: { slug: 'first' },
blog: true,
users: [
{ id: 1, first_name: 'john', last_name: 'deux' },
{ id: 2, first_name: 'zeit', last_name: 'geist' },
],
})
})
it('should render /blog/second correctly', async () => {
const browser = await webdriver(next.url, '/blog/second')
await browser.waitForElementByCss('#blog')
expect(await browser.elementByCss('#blog').text()).toBe('blog page')
expect(JSON.parse(await browser.elementByCss('#props').text())).toEqual({
params: { slug: 'second' },
blog: true,
users: [
{ id: 1, first_name: 'john', last_name: 'deux' },
{ id: 2, first_name: 'zeit', last_name: 'geist' },
],
})
})
if ((global as any).isNextStart) {
it('should output traces', async () => {
const checks = [
{
page: '/_app',
tests: [
/(webpack-runtime\.js|\[turbopack\]_runtime\.js)/,
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
isReact18
? /node_modules\/react\/cjs\/react\.production\.min\.js/
: /node_modules\/react\/cjs\/react\.production\.js/,
],
notTests: [],
},
{
page: '/blog/[slug]',
tests: [
/(webpack-runtime\.js|\[turbopack\]_runtime\.js)/,
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
isReact18
? /node_modules\/react\/cjs\/react\.production\.min\.js/
: /node_modules\/react\/cjs\/react\.production\.js/,
/node_modules\/sqlite3\/.*?\.js/,
/node_modules\/sqlite3\/.*?\.node/,
/node_modules\/sqlite\/.*?\.js/,
/node_modules\/next/,
/\/data\.sqlite/,
],
notTests: [],
},
]
for (const check of checks) {
const contents = await next.readFile(
path.join('.next/server/pages/', check.page + '.js.nft.json')
)
const { version, files } = JSON.parse(contents)
expect(version).toBe(1)
expect(
check.tests.every((item) => files.some((file) => item.test(file)))
).toBe(true)
if (path.sep === '/') {
expect(
check.notTests.some((item) => files.some((file) => item.test(file)))
).toBe(false)
}
}
})
}
})