~bigbes/lethe

ref: c01a501a4fb0fe47f94c8f36c9e18f73d9571619 lethe/web/src/test-setup.ts -rw-r--r-- 481 bytes
c01a501a — Eugene Blikh web: PKCE machinery + Authorization-header attachment in apiFetch a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
import '@testing-library/jest-dom'
import { webcrypto } from 'node:crypto'

// Polyfill crypto.subtle for jsdom environments (AS1).
// jsdom does not ship its own crypto.subtle implementation; we borrow Node's
// Web Crypto API which is spec-compliant and available in Node ≥ 19.
if (typeof globalThis.crypto === 'undefined' || !globalThis.crypto.subtle) {
  Object.defineProperty(globalThis, 'crypto', {
    value: webcrypto,
    writable: false,
    configurable: true,
  })
}