2024-02-13 08:23:07 -05:00
|
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { before, describe, it } from 'node:test';
|
2023-05-02 02:42:48 -05:00
|
|
|
import { loadFixture } from './test-utils.js';
|
2023-02-21 09:14:47 -05:00
|
|
|
|
|
|
|
describe('Serverless prerender', () => {
|
|
|
|
/** @type {import('./test-utils').Fixture} */
|
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
2023-05-17 08:23:20 -05:00
|
|
|
process.env.PRERENDER = true;
|
2023-02-21 09:14:47 -05:00
|
|
|
fixture = await loadFixture({
|
|
|
|
root: './fixtures/serverless-prerender/',
|
|
|
|
});
|
2023-07-17 07:57:27 -05:00
|
|
|
await fixture.build();
|
2023-02-21 09:14:47 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('build successful', async () => {
|
2024-02-13 08:23:07 -05:00
|
|
|
assert.ok(await fixture.readFile('../.vercel/output/static/index.html'));
|
2023-02-21 09:14:47 -05:00
|
|
|
});
|
2023-07-17 07:57:27 -05:00
|
|
|
|
2024-03-26 05:44:04 -05:00
|
|
|
it('outDir is tree-shaken if not needed', async () => {
|
|
|
|
const [file] = await fixture.glob(
|
|
|
|
'../.vercel/output/functions/_render.func/packages/integrations/vercel/test/fixtures/serverless-prerender/.vercel/output/_functions/chunks/pages/generic_*.mjs'
|
|
|
|
);
|
|
|
|
const contents = await fixture.readFile(file);
|
2024-03-26 05:45:08 -05:00
|
|
|
assert.ok(!contents.includes('const outDir ='), "outDir is tree-shaken if it's not imported");
|
2024-03-26 05:44:04 -05:00
|
|
|
});
|
|
|
|
|
2023-08-16 03:21:05 -05:00
|
|
|
// TODO: The path here seems to be inconsistent?
|
|
|
|
it.skip('includeFiles work', async () => {
|
2024-02-13 08:23:07 -05:00
|
|
|
assert.ok(
|
2023-07-17 07:57:27 -05:00
|
|
|
await fixture.readFile(
|
2023-08-16 03:21:05 -05:00
|
|
|
'../.vercel/output/functions/render.func/packages/integrations/vercel/test/fixtures/serverless-prerender/dist/middleware.mjs'
|
2023-07-17 07:57:27 -05:00
|
|
|
)
|
2024-02-13 08:23:07 -05:00
|
|
|
);
|
2023-07-17 07:57:27 -05:00
|
|
|
});
|
2023-02-21 09:14:47 -05:00
|
|
|
});
|
2023-05-17 08:23:20 -05:00
|
|
|
|
|
|
|
describe('Serverless hybrid rendering', () => {
|
|
|
|
/** @type {import('./test-utils').Fixture} */
|
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
process.env.PRERENDER = true;
|
|
|
|
fixture = await loadFixture({
|
|
|
|
root: './fixtures/serverless-prerender/',
|
2023-05-17 08:26:03 -05:00
|
|
|
output: 'hybrid',
|
2023-05-17 08:23:20 -05:00
|
|
|
});
|
2023-07-17 07:57:27 -05:00
|
|
|
await fixture.build();
|
2023-05-17 08:23:20 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('build successful', async () => {
|
2024-02-13 08:23:07 -05:00
|
|
|
assert.ok(await fixture.readFile('../.vercel/output/static/index.html'));
|
2023-05-17 08:23:20 -05:00
|
|
|
});
|
|
|
|
});
|