Closed kxalex closed 4 months ago
If you try to use with API starter (OpenAPI compliant) with vitest it fails with
√ frosty-hat-141c main* ❯ vitest 14.6s 20:31:28 DEV v1.3.0 /Users/kxalex/Projects/salesdep/frosty-hat-141c [vpw:inf] Starting single runtime for vitest.config.ts... · test/index.spec.ts (1) · dispatches fetch event workerd/io/worker.c++:1874: info: uncaught exception; source = Uncaught (in promise); stack = TypeError: Cannot use require() to import an ES Module. at Users/kxalex/Projects/salesdep/frosty-hat-141c/node_modules/openapi3-ts/dist/oas30-CAmzubQd.js:1:22 at Users/kxalex/Projects/salesdep/frosty-hat-141c/node_modules/openapi3-ts/dist/oas30.js?mf_vitest_no_cjs_esm_shim:1:27 at Users/kxalex/Projects/salesdep/frosty-hat-141c/node_modules/@asteasolutions/zod-to-openapi/dist/index.js?mf_vitest_no_cjs_esm_shim:35:34 workerd/io/io-context.c++:355: info: uncaught exception; exception = workerd/jsg/_virtual_includes/jsg/workerd/jsg/value.h:1333: failed: jsg.TypeError: Cannot use r ❯ test/index.spec.ts (1) × dispatches fetch event ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ FAIL test/index.spec.ts > dispatches fetch event TypeError: Cannot use require() to import an ES Module. ❯ test/index.spec.ts:5:22 3| 4| it("dispatches fetch event", async () => { 5| const response = await SELF.fetch("https://google.com"); | ^ 6| expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`); 7| }); ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { remote: true } ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ Test Files 1 failed (1) Tests 1 failed (1) Start at 20:31:29 Duration 836ms (transform 17ms, setup 0ms, collect 16ms, tests 48ms, environment 0ms, prepare 183ms) FAIL Tests failed. Watching for file changes... press h to show help, press q to quit Cancelling test run. Press CTRL+c again to exit forcefully.
Reproduce repo: https://github.com/kxalex/frosty-hat-141c
The problem in @asteasolutions/zod-to-openapi library.
I've pulled @cloudflare/itty-router-openapi and upgraded to 6.4.0! It fixes the problem!
Could you please upgrade @asteasolutions/zod-to-openapi to 6.4.0 (7.0.0 is not backward compatible).
Hey @kxalex i've just published a new released that updates @asteasolutions/zod-to-openapi to 6.4.0 Can you confirm the issue is solved? Thanks for reporting this, and proposing a solution
Thanks. It's fixed now.
If you try to use with API starter (OpenAPI compliant) with vitest it fails with
Reproduce repo: https://github.com/kxalex/frosty-hat-141c
The problem in @asteasolutions/zod-to-openapi library.
I've pulled @cloudflare/itty-router-openapi and upgraded to 6.4.0! It fixes the problem!
Could you please upgrade @asteasolutions/zod-to-openapi to 6.4.0 (7.0.0 is not backward compatible).