Files
astro/packages/astro/test/ssr-markdown.nodetest.js
2024-02-16 11:41:16 +00:00

34 lines
948 B
JavaScript

import assert from 'node:assert/strict';
import { describe, before, it } from 'node:test';
import { load as cheerioLoad } from 'cheerio';
import { loadFixture } from './test-utils.js';
import testAdapter from './test-adapter.js';
describe('Markdown pages in SSR', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
root: './fixtures/ssr-markdown/',
output: 'server',
adapter: testAdapter(),
});
await fixture.build();
});
async function fetchHTML(path) {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com' + path);
const response = await app.render(request);
const html = await response.text();
return html;
}
it('Renders markdown pages correctly', async () => {
const html = await fetchHTML('/post');
const $ = cheerioLoad(html);
assert.equal($('#subheading').text(), 'Subheading');
});
});