2023-07-17 14:53:10 +00:00
|
|
|
import { loadFixture } from './test-utils.ts';
|
2022-06-07 15:41:32 +00:00
|
|
|
import { assertEquals, assert, DOMParser } from './deps.ts';
|
|
|
|
|
|
|
|
Deno.test({
|
|
|
|
name: 'Dynamic imports',
|
2023-07-17 14:53:10 +00:00
|
|
|
permissions: 'inherit',
|
2022-06-07 15:41:32 +00:00
|
|
|
async fn() {
|
2023-07-17 14:53:10 +00:00
|
|
|
const { runApp, runBuild } = await loadFixture('./fixtures/dynimport/');
|
|
|
|
await runBuild();
|
2023-05-17 13:23:20 +00:00
|
|
|
const stop = await runApp('./fixtures/dynimport/prod.js');
|
2022-06-07 15:41:32 +00:00
|
|
|
|
|
|
|
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`);
|
2023-07-17 14:53:10 +00:00
|
|
|
if (doc) {
|
|
|
|
const div = doc.querySelector('#thing');
|
|
|
|
assert(div, 'div exists');
|
|
|
|
}
|
2022-06-21 12:33:55 +00:00
|
|
|
} catch (err) {
|
2022-06-21 12:32:05 +00:00
|
|
|
console.error(err);
|
2022-06-07 15:41:32 +00:00
|
|
|
} finally {
|
|
|
|
await stop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|