-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathserve.ts
More file actions
25 lines (20 loc) · 906 Bytes
/
serve.ts
File metadata and controls
25 lines (20 loc) · 906 Bytes
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
import assert from 'node:assert/strict';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { executeBrowserTest } from '../../utils/puppeteer';
export default async function () {
// Serve works without HMR
const noHmrPort = await ngServe('--no-hmr');
await verifyResponse(noHmrPort);
await killAllProcesses();
// Serve works with HMR
const hmrPort = await ngServe('--hmr');
await verifyResponse(hmrPort);
await executeBrowserTest({ baseUrl: `http://localhost:${hmrPort}/` });
}
async function verifyResponse(port: number): Promise<void> {
const indexResponse = await fetch(`http://localhost:${port}/`);
assert.match(await indexResponse.text(), /<app-root><\/app-root>/);
const assetResponse = await fetch(`http://localhost:${port}/favicon.ico`);
assert(assetResponse.ok, 'Expected favicon asset to be available.');
}