Skip to content

Commit 8922ada

Browse files
committed
add vitest config
1 parent cfa0615 commit 8922ada

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
globals: true,
6+
environment: 'node',
7+
setupFiles: ['./vitest.setup.ts'],
8+
include: ['test/**/*.test.ts']
9+
}
10+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { webcrypto } from 'node:crypto';
2+
3+
// Polyfill globalThis.crypto for environments (e.g. Node 18) where it is not defined.
4+
// This is necessary for the tests to run in Node 18, specifically for the jose library, which relies on the globalThis.crypto object.
5+
if (typeof globalThis.crypto === 'undefined') {
6+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7+
(globalThis as any).crypto = webcrypto as unknown as Crypto;
8+
}

0 commit comments

Comments
 (0)