Skip to content

Commit c9140ee

Browse files
committed
feat: switch to vitest and fix mocks
1 parent a003fe2 commit c9140ee

File tree

6 files changed

+886
-2019
lines changed

6 files changed

+886
-2019
lines changed

jest.config.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/__tests__/mocks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type JWK, SignJWT, exportJWK, generateKeyPair, importJWK } from 'jose';
22
import { type SessionManager } from '../sdk/session-managers';
3+
import { vi } from 'vitest';
34

45
let mockPrivateKey: JWK | undefined;
56
let mockPublicKey: JWK | undefined;
@@ -11,7 +12,7 @@ export const getKeys = async (): Promise<{ privateKey: JWK; publicKey: JWK }> =>
1112
return { privateKey: mockPrivateKey, publicKey: mockPublicKey };
1213
}
1314
const { publicKey: generatedPublicKey, privateKey: generatedPrivateKey } =
14-
await generateKeyPair(mockJwtAlg);
15+
await generateKeyPair(mockJwtAlg, { extractable: true });
1516

1617
const generatedPrivateJwk = await exportJWK(generatedPrivateKey);
1718
const generatedPublicJwk = await exportJWK(generatedPublicKey);
@@ -22,7 +23,7 @@ export const getKeys = async (): Promise<{ privateKey: JWK; publicKey: JWK }> =>
2223
return { privateKey: mockPrivateKey, publicKey: mockPublicKey };
2324
};
2425

25-
export const fetchClient = jest.fn().mockImplementation(
26+
export const fetchClient = vi.fn().mockImplementation(
2627
async () =>
2728
await Promise.resolve({
2829
json: async () => {

lib/__tests__/sdk/utilities/feature-flags.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as mocks from '../../mocks';
2+
import { describe, it, expect, beforeAll, beforeEach, afterEach } from 'vitest';
23

34
import {
45
type FeatureFlags,

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"prebuild": "node sdk-version.js && rimraf dist dist-cjs lib/models lib/apis",
2828
"lint": "eslint . && prettier . --check",
2929
"lint:fix": "eslint --fix . && prettier . --write",
30-
"test": "jest --passWithNoTests",
30+
"test": "vitest",
3131
"lint-staged": "lint-staged",
3232
"husky": "husky install",
3333
"generate": "npx @openapitools/openapi-generator-cli generate -i ./kinde-mgmt-api-specs.yaml -c ./generator-config.yaml -g typescript-fetch -o ./lib --additional-properties=importFileExtension=.js"
@@ -47,10 +47,10 @@
4747
"devDependencies": {
4848
"@openapitools/openapi-generator-cli": "^2.7.0",
4949
"@tsconfig/node18": "^2.0.1",
50-
"@types/jest": "^29.5.14",
5150
"@types/jsdom": "^21.1.1",
5251
"@types/node": "^20.2.1",
5352
"@typescript-eslint/eslint-plugin": "^7",
53+
"@vitest/coverage-v8": "^1.3.1",
5454
"eslint": "^9.24.0",
5555
"eslint-config-prettier": "^10.1.2",
5656
"eslint-config-standard-with-typescript": "^43.0.1",
@@ -59,15 +59,13 @@
5959
"eslint-plugin-prettier": "^5.2.6",
6060
"eslint-plugin-promise": "^7.2.1",
6161
"husky": "^8.0.3",
62-
"jest": "^29.7.0",
63-
"jest-environment-jsdom": "^29.5.0",
6462
"jsdom": "^22.0.0",
6563
"lint-staged": "^13.2.2",
6664
"ncp": "^2.0.0",
6765
"prettier": "^3.5.3",
6866
"rimraf": "^6.0.1",
69-
"ts-jest": "^29.3.2",
70-
"typescript": "^5.8.3"
67+
"typescript": "^5.8.3",
68+
"vitest": "^1.3.1"
7169
},
7270
"dependencies": {
7371
"@kinde/js-utils": "^0.18.1",

0 commit comments

Comments
 (0)