aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/node/test/node-middleware.test.js
blob: a658f93ef8416d62be5f2604306cb61faeeee561 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import nodejs from '../dist/index.js';
import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
import * as cheerio from 'cheerio';

describe('test 404 cant load', () => {
	let fixture;
	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/node-middleware/',
			output: 'server',
			adapter: nodejs({ mode: 'standalone' }),
		});
		await fixture.build();
	});
	describe('test 404', async () => {
		let devPreview;

		before(async () => {
			devPreview = await fixture.preview();
		});
		after(async () => {
			await devPreview.stop();
		});
		it('when mode is standalone', async () => {
			const res = await fixture.fetch('/error-page');

			expect(res.status).to.equal(404);

			const html = await res.text();
			const $ = cheerio.load(html);

			const h1 = $('h1');
			expect(h1.text()).to.equal('404!!!!!!!!!!');
		});
	});
});