Skip to content

Commit

Permalink
Mock globalThis.crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz committed Nov 22, 2024
1 parent fb9a252 commit d315849
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cryptography.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import {
sha256,
} from './cryptography';
import * as utils from './utils';

Check failure on line 10 in src/cryptography.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

There should be at least one empty line between import groups
import { webcrypto } from 'crypto';

Check failure on line 11 in src/cryptography.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

`crypto` import should occur before import of `./cryptography`

// Node.js <20 doesn't have `globalThis.crypto`, so we need to define it.
// TODO: Remove this once we drop support for Node.js <20.
Object.defineProperty(globalThis, 'crypto', webcrypto);

describe('hmacSha512', () => {
it('returns the HMAC-SHA-512 when using a custom implementation', async () => {
Expand Down

0 comments on commit d315849

Please sign in to comment.