diff options
author | 2023-09-25 15:52:27 -0400 | |
---|---|---|
committer | 2023-10-15 08:36:37 +0200 | |
commit | 1e0610b088a518ea257287da9d1bc0ccd15cb522 (patch) | |
tree | b970fe5815dea1d5386e645e232a902cd83c022b /packages/integrations/netlify/test/functions/prerender.test.js | |
parent | b750be65ff69c5c219f3f74abbc1e6f8a64e6830 (diff) | |
download | astro-1e0610b088a518ea257287da9d1bc0ccd15cb522.tar.gz astro-1e0610b088a518ea257287da9d1bc0ccd15cb522.tar.zst astro-1e0610b088a518ea257287da9d1bc0ccd15cb522.zip |
chore(netlify): fixes after migration
Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Co-authored-by: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com>
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'); |