0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/cloudflare/test/prerender.test.js
Marco Schumacher ea30a9d4f2
more efficient _routes.json for cloudflare integration (#7846)
* more efficient _routes.json for cloudflare integration

* added tests

* updated pnpm-lock.yaml

* added changeset

* cleaned up test

* fix: convert window path separators

* updated docs

* handle more cases

* Apply suggestions from code review

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

* incorporate feedback from code review

* used other pnpm version

* better fallback for empty include array

* adjust test case to changed fallback for empty include array

* updated docs

---------

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
2023-08-10 04:04:09 +01:00

58 lines
1.2 KiB
JavaScript

import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
describe('Prerendering', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
process.env.PRERENDER = true;
fixture = await loadFixture({
root: './fixtures/prerender/',
});
await fixture.build();
});
after(() => {
delete process.env.PRERENDER;
fixture.clean();
});
it('includes non prerendered routes in the routes.json config', async () => {
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json'));
expect(foundRoutes).to.deep.equal({
version: 1,
include: ['/'],
exclude: [],
});
});
});
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;
});
it('includes non prerendered routes in the routes.json config', async () => {
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json'));
expect(foundRoutes).to.deep.equal({
version: 1,
include: ['/one'],
exclude: [],
});
});
});