Skip to content

Commit 9da007f

Browse files
authored
Updated testing doc wiht polyfills (#441)
1 parent cb1c5c9 commit 9da007f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/articles/testing.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,20 @@ describe("myFunction", () => {
202202
});
203203
});
204204
```
205+
206+
### Polyfills
207+
208+
If you are running unit tests in a Node.js environment, you may need to polyfill
209+
some globals. Zuplo itself does not run on Node.js, but because Zuplo is built
210+
on standard API, testing in Node.js is possible.
211+
212+
If you are running on Node.js 20 or later, you can use the `webcrypto` module to
213+
polyfill the `crypto` global. You must register this polyfill before any Zuplo
214+
code runs.
215+
216+
```js
217+
import { webcrypto } from "node:crypto";
218+
if (typeof crypto === "undefined") {
219+
globalThis.crypto = webcrypto;
220+
}
221+
```

0 commit comments

Comments
 (0)