summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/edge-functions/dynamic-import.test.js
blob: b23f9b4c4879b638ac33297f31af78add246222a (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
// @ts-ignore
import { runBuild, runApp } from './test-utils.ts';
// @ts-ignore
import { assertEquals, assert, DOMParser } from './deps.ts';

// @ts-ignore
Deno.test({
	name: 'Dynamic imports',
	async fn() {
		let close = await runBuild('./fixtures/dynimport/');
		let stop = await runApp('./fixtures/dynimport/prod.js');

		try {
			const response = await fetch('http://127.0.0.1:8085/');
			assertEquals(response.status, 200);
			const html = await response.text();

			assert(html, 'got some html');
			const doc = new DOMParser().parseFromString(html, `text/html`);
			const div = doc.querySelector('#thing');
			assert(div, 'div exists');
		} catch(err) {
			console.error(err);
		} finally {
			await close();
			await stop();
		}
	},
});