70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import dedent from "ts-dedent";
|
|
import { test, vitestConfig } from "./helpers";
|
|
|
|
test("chunks large WebSocket messages bi-directionally", async ({
|
|
expect,
|
|
seed,
|
|
vitestRun,
|
|
}) => {
|
|
// Check loads module greater than 1 MiB `workerd` limit...
|
|
const bigText = "xyz".repeat(400_000);
|
|
await seed({
|
|
"big.txt": bigText,
|
|
"vitest.config.mts": vitestConfig({
|
|
miniflare: {
|
|
compatibilityDate: "2025-12-02",
|
|
compatibilityFlags: ["nodejs_compat"],
|
|
modulesRules: [{ type: "Text", include: ["**/*.txt"] }],
|
|
},
|
|
}),
|
|
"index.test.ts": dedent`
|
|
import text from "./big.txt";
|
|
import { it } from "vitest";
|
|
it("logs big text", () => {
|
|
console.log(text);
|
|
});
|
|
`,
|
|
});
|
|
// Increase buffer size to allow the `exec` command to receive this large output.
|
|
// If this is not big enough the child process running Vitest will exit with a SIGINT signal
|
|
const result = await vitestRun({ maxBuffer: bigText.length + 10000 });
|
|
await result.exitCode;
|
|
// ...and logs it back
|
|
expect(result.stdout).toMatch(bigText);
|
|
expect(await result.exitCode).toBe(0);
|
|
});
|