mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
b6e44f91ad
Some `deno_std` tests were failing to print output that was resolved after the last test finished. In addition, output printed before tests began would sometimes appear above the "running X tests ..." line, and sometimes below it depending on timing. We now guarantee that all output is flushed before and after tests run, making the output consistent. Pre-test and post-test output are captured in `------ pre-test output ------` and `------ post-test output ------` blocks to differentiate them from the regular output blocks. Here's an example of a test (that is much noisier than normal, but an example of what the output will look like): ``` Check ./load_unload.ts ------- pre-test output ------- load ----- output end ----- running 1 test from ./load_unload.ts test ... ------- output ------- test ----- output end ----- test ... ok ([WILDCARD]) ------- post-test output ------- unload ----- output end ----- ```
29 lines
894 B
TypeScript
29 lines
894 B
TypeScript
import { assertEquals } from "../../../tests/util/std/assert/mod.ts";
|
|
|
|
const errorDeferred = Promise.withResolvers<void>();
|
|
const closeDeferred = Promise.withResolvers<void>();
|
|
|
|
const listener = Deno.listen({ port: 4509 });
|
|
console.log("READY");
|
|
const httpConn = Deno.serveHttp(await listener.accept());
|
|
const { request, respondWith } = (await httpConn.nextRequest())!;
|
|
const { response, socket } = Deno.upgradeWebSocket(request, {
|
|
idleTimeout: 1,
|
|
});
|
|
socket.onerror = (e) => {
|
|
console.log(e);
|
|
assertEquals((e as ErrorEvent).message, "No response from ping frame.");
|
|
errorDeferred.resolve();
|
|
};
|
|
socket.onclose = (e) => {
|
|
console.log(e);
|
|
assertEquals(e.reason, "No response from ping frame.");
|
|
closeDeferred.resolve();
|
|
};
|
|
await respondWith(response);
|
|
|
|
await errorDeferred.promise;
|
|
await closeDeferred.promise;
|
|
|
|
// TODO(mmastrac): this doesn't exit on its own. Why?
|
|
Deno.exit(123);
|