Skip to content

Commit

Permalink
Bump to use node 20 (#4)
Browse files Browse the repository at this point in the history
* bump to use node 20

* use fetch pool forks

to prevent leaving processes running in the background, see https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker
  • Loading branch information
DavidSint authored Feb 3, 2024
1 parent 4fad6c2 commit 3c9f77d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/merge-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
- name: Install and build
run: npm ci && npm run build
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Install and build
run: npm ci && npm run build
Expand Down
21 changes: 12 additions & 9 deletions lib/tests/hibp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ describe("Have I Been Pwned", () => {
test("non-node web crypto API hash", async () => {
const cryptoSafeBox = globalThis.crypto;

globalThis.crypto = {
getRandomValues: vi
.fn()
.mockImplementation(async () => new ArrayBuffer(16)),
randomUUID: vi.fn() as MockedFunction<typeof cryptoSafeBox.randomUUID>,
subtle: {
...cryptoSafeBox?.subtle,
digest: vi.fn().mockImplementation(async () => new ArrayBuffer(16)),
Object.defineProperty(globalThis, "crypto", {
value: {
getRandomValues: vi
.fn()
.mockImplementation(async () => new ArrayBuffer(16)),
randomUUID: vi.fn() as MockedFunction<typeof cryptoSafeBox.randomUUID>,
subtle: {
...cryptoSafeBox?.subtle,
digest: vi.fn().mockImplementation(async () => new ArrayBuffer(16)),
},
},
};
writable: true,
});

await createSha1Hash("123934534f", {} as NodeJS.Process);

Expand Down
5 changes: 4 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ module.exports = defineConfig({
fileName: (format) => `password-tester.${format}.js`
}
},
plugins: [dts()]
plugins: [dts()],
test: {
pool: 'forks',
},
})

0 comments on commit 3c9f77d

Please sign in to comment.