2023-01-26 17:43:39 +00:00
|
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
import { expect } from 'chai';
|
|
|
|
|
|
|
|
describe('Prerendering', () => {
|
|
|
|
/** @type {import('./test-utils').Fixture} */
|
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
2023-05-17 13:23:20 +00:00
|
|
|
process.env.PRERENDER = true;
|
2023-01-26 17:43:39 +00:00
|
|
|
fixture = await loadFixture({
|
|
|
|
root: './fixtures/prerender/',
|
|
|
|
});
|
|
|
|
await fixture.build();
|
|
|
|
});
|
|
|
|
|
2023-05-17 13:23:20 +00:00
|
|
|
after(() => {
|
|
|
|
delete process.env.PRERENDER;
|
|
|
|
fixture.clean();
|
|
|
|
});
|
|
|
|
|
2023-08-10 03:04:09 +00:00
|
|
|
it('includes non prerendered routes in the routes.json config', async () => {
|
|
|
|
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json'));
|
2023-05-17 13:23:20 +00:00
|
|
|
|
2023-08-10 03:04:09 +00:00
|
|
|
expect(foundRoutes).to.deep.equal({
|
|
|
|
version: 1,
|
|
|
|
include: ['/'],
|
|
|
|
exclude: [],
|
|
|
|
});
|
2023-05-17 13:23:20 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Hybrid rendering', () => {
|
|
|
|
/** @type {import('./test-utils').Fixture} */
|
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
process.env.PRERENDER = false;
|
|
|
|
fixture = await loadFixture({
|
|
|
|
root: './fixtures/prerender/',
|
|
|
|
output: 'hybrid',
|
|
|
|
});
|
|
|
|
await fixture.build();
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
delete process.env.PRERENDER;
|
|
|
|
});
|
|
|
|
|
2023-08-10 03:04:09 +00:00
|
|
|
it('includes non prerendered routes in the routes.json config', async () => {
|
|
|
|
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json'));
|
2023-05-17 13:23:20 +00:00
|
|
|
|
2023-08-10 03:04:09 +00:00
|
|
|
expect(foundRoutes).to.deep.equal({
|
|
|
|
version: 1,
|
|
|
|
include: ['/one'],
|
|
|
|
exclude: [],
|
|
|
|
});
|
2023-01-26 17:43:39 +00:00
|
|
|
});
|
|
|
|
});
|