0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/vercel/test/edge-middleware.test.js
Emanuele Stoppa d4a6ab7339
fix(ssr): inline middleware during the build, not rely on file system (#8300)
* fix(ssr): inline middleware during the build, not rely on file system

* feedback

* chore: fix lint

---------

Co-authored-by: Nate Moore <nate@astro.build>
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
2023-08-30 12:56:10 -05:00

35 lines
1.5 KiB
JavaScript

import { expect } from 'chai';
import chaiJestSnapshot from 'chai-jest-snapshot';
import { loadFixture } from './test-utils.js';
describe('Vercel edge middleware', () => {
// TODO: The path here seems to be inconsistent?
it.skip('with edge handle file, should successfully build the middleware', async () => {
const fixture = await loadFixture({
root: './fixtures/middleware-with-edge-file/',
});
await fixture.build();
const contents = await fixture.readFile(
// this is abysmal...
'../.vercel/output/functions/render.func/www/withastro/astro/packages/integrations/vercel/test/fixtures/middleware-with-edge-file/dist/middleware.mjs'
);
expect(contents.includes('title:')).to.be.true;
chaiJestSnapshot.setTestName('Middleware with handler file');
expect(contents).to.matchSnapshot(true);
});
// TODO: The path here seems to be inconsistent?
it.skip('without edge handle file, should successfully build the middleware', async () => {
const fixture = await loadFixture({
root: './fixtures/middleware-without-edge-file/',
});
await fixture.build();
const contents = await fixture.readFile(
// this is abysmal...
'../.vercel/output/functions/render.func/www/withastro/astro/packages/integrations/vercel/test/fixtures/middleware-without-edge-file/dist/middleware.mjs'
);
expect(contents.includes('title:')).to.be.false;
chaiJestSnapshot.setTestName('Middleware without handler file');
expect(contents).to.matchSnapshot(true);
});
});