diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/js/third_party/comlink/comlink.test.ts | 15 | ||||
-rw-r--r-- | test/js/third_party/comlink/package.json | 6 | ||||
-rw-r--r-- | test/js/third_party/comlink/worker.fixture.ts | 9 | ||||
-rw-r--r-- | test/package.json | 3 |
4 files changed, 32 insertions, 1 deletions
diff --git a/test/js/third_party/comlink/comlink.test.ts b/test/js/third_party/comlink/comlink.test.ts new file mode 100644 index 000000000..77d810950 --- /dev/null +++ b/test/js/third_party/comlink/comlink.test.ts @@ -0,0 +1,15 @@ +import { test, expect, describe } from "bun:test"; +import { join } from "path"; +import * as Comlink from "comlink"; + +describe("comlink", () => { + test("should start without big delay", async () => { + const worker = new Worker(join(import.meta.dir, "worker.fixture.ts")); + const obj = Comlink.wrap(worker); + const start = performance.now(); + //@ts-ignore + await obj.counter; + const end = performance.now(); + expect(end - start).toBeLessThan(100); + }); +}); diff --git a/test/js/third_party/comlink/package.json b/test/js/third_party/comlink/package.json new file mode 100644 index 000000000..707196be3 --- /dev/null +++ b/test/js/third_party/comlink/package.json @@ -0,0 +1,6 @@ +{ + "name": "comlink", + "dependencies": { + "comlink": "4.4.1" + } +} diff --git a/test/js/third_party/comlink/worker.fixture.ts b/test/js/third_party/comlink/worker.fixture.ts new file mode 100644 index 000000000..1cfcfbe9f --- /dev/null +++ b/test/js/third_party/comlink/worker.fixture.ts @@ -0,0 +1,9 @@ +import * as Comlink from "comlink"; +const obj = { + counter: 0, + inc() { + this.counter++; + }, +}; + +Comlink.expose(obj); diff --git a/test/package.json b/test/package.json index b7e84b19a..bc4ed1d8c 100644 --- a/test/package.json +++ b/test/package.json @@ -30,7 +30,8 @@ "undici": "5.20.0", "vitest": "0.32.2", "webpack": "5.88.0", - "webpack-cli": "4.7.2" + "webpack-cli": "4.7.2", + "comlink": "4.4.1" }, "private": true, "scripts": { |