Skip to content

Commit

Permalink
♻️ Do not explicity import crypto in the lib file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardstanislas committed Mar 23, 2023
1 parent 66dee8f commit fe80ac8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/lib/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import crypto from 'crypto';

const subtle = crypto.subtle;
const subtle = globalThis.crypto.subtle;
const encryption = {
name: 'RSA-OAEP'
};
Expand Down
5 changes: 5 additions & 0 deletions tests/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import crypto from 'crypto';

export default () => {
globalThis.crypto = crypto as unknown as Crypto;
};
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
include: ['src/**/*.{test,spec}.{js,ts}'],
globalSetup: 'tests/globalSetup.ts'
}
});

1 comment on commit fe80ac8

@vercel
Copy link

@vercel vercel bot commented on fe80ac8 Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.