-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
test.utils.ts
36 lines (29 loc) · 862 Bytes
/
test.utils.ts
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
import { assert, TextProtoReader, BufReader } from "../src/deps_test.ts";
let server: Deno.Process;
export async function startServer(serverPath: string): Promise<void> {
server = Deno.run({
cmd: [
Deno.execPath(),
"run",
"-A",
"--config",
"./src/tsconfig.lib.json",
serverPath,
],
stdout: "piped",
stderr: "inherit",
});
// Once server is ready it will write to its stdout.
assert(server.stdout != null);
const r = new TextProtoReader(new BufReader(server.stdout as any));
let s = await r.readLine();
assert(s !== null && s.includes("Server start in"));
return Promise.resolve();
}
export function killServer(): void {
server.close();
(server.stdout as any)?.close();
}
export function itLog(s: string, firstIt = false): void {
firstIt ? console.log("\n" + s) : console.log(s);
}