Skip to content

Commit

Permalink
Updated testing doc wiht polyfills (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntotten authored Dec 16, 2024
1 parent cb1c5c9 commit 9da007f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/articles/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,20 @@ describe("myFunction", () => {
});
});
```

### Polyfills

If you are running unit tests in a Node.js environment, you may need to polyfill
some globals. Zuplo itself does not run on Node.js, but because Zuplo is built
on standard API, testing in Node.js is possible.

If you are running on Node.js 20 or later, you can use the `webcrypto` module to
polyfill the `crypto` global. You must register this polyfill before any Zuplo
code runs.

```js
import { webcrypto } from "node:crypto";
if (typeof crypto === "undefined") {
globalThis.crypto = webcrypto;
}
```

0 comments on commit 9da007f

Please sign in to comment.