0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/node/test/preview-headers.test.js
Furkan Erdem 8cd38f0245
Fix(node): Custom headers are not present in responses from standalone Node server in preview mode (#10208)
* fix(node): add user specified headers to preview server responses

* docs: clarify comment

* style: new line

* test: remove test

* chore: add changeset
2024-02-23 08:23:33 -05:00

38 lines
939 B
JavaScript

import * as assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import nodejs from '../dist/index.js';
import { loadFixture } from './test-utils.js';
describe('Astro preview headers', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
let devPreview;
const headers = {
astro: 'test',
};
before(async () => {
fixture = await loadFixture({
root: './fixtures/preview-headers/',
output: 'server',
adapter: nodejs({ mode: 'standalone' }),
server: {
headers
},
});
await fixture.build();
devPreview = await fixture.preview();
});
after(async () => {
await devPreview.stop();
});
describe('Preview Headers', () => {
it('returns custom headers for valid URLs', async () => {
const result = await fixture.fetch('/');
assert.equal(result.status, 200);
assert.equal(Object.fromEntries(result.headers).astro, headers.astro);
});
});
});