diff options
Diffstat (limited to 'packages/integrations/netlify/test/functions/prerender.test.js')
-rw-r--r-- | packages/integrations/netlify/test/functions/prerender.test.js | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/packages/integrations/netlify/test/functions/prerender.test.js b/packages/integrations/netlify/test/functions/prerender.test.js index 2028e89c3..8acc5a519 100644 --- a/packages/integrations/netlify/test/functions/prerender.test.js +++ b/packages/integrations/netlify/test/functions/prerender.test.js @@ -1,23 +1,14 @@ import { expect } from 'chai'; -import netlifyAdapter from '../../dist/index.js'; -import { loadFixture, testIntegration } from './test-utils.js'; +import fs from 'fs/promises'; +import { cli } from './test-utils.js'; +import { fileURLToPath } from 'url'; -describe('Mixed Prerendering with SSR', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; +const root = new URL('./fixtures/prerender/', import.meta.url).toString(); +describe('Mixed Prerendering with SSR', () => { before(async () => { process.env.PRERENDER = true; - fixture = await loadFixture({ - root: new URL('./fixtures/prerender/', import.meta.url).toString(), - output: 'server', - adapter: netlifyAdapter({ - dist: new URL('./fixtures/prerender/dist/', import.meta.url), - }), - site: `http://example.com`, - integrations: [testIntegration()], - }); - await fixture.build(); + await cli('build', '--root', fileURLToPath(root)); }); after(() => { @@ -25,7 +16,7 @@ describe('Mixed Prerendering with SSR', () => { }); it('Wildcard 404 is sorted last', async () => { - const redir = await fixture.readFile('/_redirects'); + const redir = await fs.readFile(new URL('./dist/_redirects', root), 'utf-8'); const baseRouteIndex = redir.indexOf('/ /.netlify/functions/entry 200'); const oneRouteIndex = redir.indexOf('/one /one/index.html 200'); const fourOhFourWildCardIndex = redir.indexOf('/* /.netlify/functions/entry 404'); @@ -37,21 +28,10 @@ describe('Mixed Prerendering with SSR', () => { }); describe('Mixed Hybrid rendering with SSR', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - before(async () => { process.env.PRERENDER = false; - fixture = await loadFixture({ - root: new URL('./fixtures/prerender/', import.meta.url).toString(), - output: 'hybrid', - adapter: netlifyAdapter({ - dist: new URL('./fixtures/prerender/dist/', import.meta.url), - }), - site: `http://example.com`, - integrations: [testIntegration()], - }); - await fixture.build(); + process.env.ASTRO_OUTPUT = 'hybrid'; + await cli('build', '--root', fileURLToPath(root)); }); after(() => { @@ -59,8 +39,7 @@ describe('Mixed Hybrid rendering with SSR', () => { }); it('outputs a correct redirect file', async () => { - const redir = await fixture.readFile('/_redirects'); - console.log(redir); + const redir = await fs.readFile(new URL('./dist/_redirects', root), 'utf-8'); const baseRouteIndex = redir.indexOf('/one /.netlify/functions/entry 200'); const rootRouteIndex = redir.indexOf('/ /index.html 200'); const fourOhFourIndex = redir.indexOf('/404 /404.html 200'); |