Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/dash-wasm/src/test/no-stdio.test.ts
1067 views
1
/*
2
Test disabling using stdio in node.js.
3
*/
4
5
import { asyncDash } from "../node";
6
import { delay } from "awaiting";
7
8
test("use noStdio", async () => {
9
const dash = await asyncDash({ noStdio: true });
10
// capture stdout and stderr to a string. Actual stdout/stderr is a Buffer.
11
let stdout = "";
12
dash.kernel.on("stdout", (data) => {
13
stdout += data.toString();
14
});
15
16
dash.terminal();
17
18
// send 389 + 5077
19
await dash.kernel.writeToStdin("echo $((389+5077))\n");
20
21
// output is buffered, so it can take a little while before it appears.
22
const t0 = new Date().valueOf();
23
while (
24
new Date().valueOf() - t0 < 5000 &&
25
!stdout.includes(`${389 + 5077}`)
26
) {
27
await delay(50);
28
}
29
expect(stdout).toContain(`${389 + 5077}`);
30
31
await dash.kernel.terminate();
32
});
33
34