2023-01-26 12:43:39 -05: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 08:23:20 -05:00
|
|
|
process.env.PRERENDER = true;
|
2023-01-26 12:43:39 -05:00
|
|
|
fixture = await loadFixture({
|
|
|
|
root: './fixtures/prerender/',
|
|
|
|
});
|
|
|
|
await fixture.build();
|
|
|
|
});
|
|
|
|
|
2023-05-17 08:23:20 -05:00
|
|
|
after(() => {
|
|
|
|
delete process.env.PRERENDER;
|
|
|
|
fixture.clean();
|
|
|
|
});
|
|
|
|
|
2023-08-09 22:04:09 -05:00
|
|
|
it('includes non prerendered routes in the routes.json config', async () => {
|
|
|
|
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json'));
|
2023-05-17 08:23:20 -05:00
|
|
|
|
2023-08-09 22:04:09 -05:00
|
|
|
expect(foundRoutes).to.deep.equal({
|
|
|
|
version: 1,
|
2023-08-16 03:21:05 -05:00
|
|
|
include: ['/', '/_image'],
|
2023-08-09 22:04:09 -05:00
|
|
|
exclude: [],
|
|
|
|
});
|
2023-05-17 08:23:20 -05: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-09 22:04:09 -05:00
|
|
|
it('includes non prerendered routes in the routes.json config', async () => {
|
|
|
|
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json'));
|
2023-05-17 08:23:20 -05:00
|
|
|
|
2023-08-09 22:04:09 -05:00
|
|
|
expect(foundRoutes).to.deep.equal({
|
|
|
|
version: 1,
|
2023-08-16 03:21:05 -05:00
|
|
|
include: ['/one', '/_image'],
|
2023-08-09 22:04:09 -05:00
|
|
|
exclude: [],
|
|
|
|
});
|
2023-01-26 12:43:39 -05:00
|
|
|
});
|
|
|
|
});
|