Skip to content
Commit Detail

Commit 98ed71b

Author
Kenton Varda <kenton@cloudflare.com> 2025-06-29 15:10:56 -0500
Parents
a6c77b0
Tree
c0b0260
Ask Claude to write more tests for worker-loader.

Prompt:

```
deps/workerd/src/workerd/api/worker-loader-test.js contains tests for the new "dynamic worker loader" feature, but needs more test cases.

Please add the following tests:
- Test non-string modules types. The source code of a module, instead of being a string, can be an object, like `{text: "blah"}`, to represent a module type other than an ES module. The types are `js` (ES module, but more explicit), `cjs` (CommonJS module), `text` (just a string), `data` (just an ArrayBuffer), and `json` (arbitrary JS object as long as it is JSON-serializable).
- Test setting compat date / flags works.
- Test code loader callback that does something asynchronous (can just wait for a 1ms timeout)
- Test what happens if the code getter callback throws an exception (it should propagate to the caller when it tries to call into the worker).

Please add the tests to the end of the file in the order listed above.

The worker loader API, if you need to refer to it, is defined in deps/workerd/src/workerd/api/worker-loader.h (in JSG format).
```

I significantly rewrote the compatDateFlags test (Claude's version didn't really test dates), and made a couple other minor tweaks, but otherwise this is mostly Claude's work at a cost of $0.29.

This actually caught a bug, fixed up in a928d9280dd09ef761b25fc749f187f51803f0a2.

Files changed

1 file changed~1 modified