From d45cd37f9b3998f15881ae161a280f7dd630fdfb Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Thu, 28 Mar 2024 10:21:50 +0800 Subject: [PATCH] refactor: use vitest for connectors (#5562) --- packages/connectors/.gitignore | 3 +- .../connector-alipay-native/package.json | 5 +- .../connector-alipay-native/src/index.test.ts | 40 +- .../connector-alipay-native/src/utils.test.ts | 8 +- .../connector-alipay-web/package.json | 5 +- .../connector-alipay-web/src/index.test.ts | 36 +- .../connector-alipay-web/src/utils.test.ts | 8 +- .../connector-aliyun-dm/package.json | 5 +- .../connector-aliyun-dm/src/index.test.ts | 10 +- .../src/single-send-mail.test.ts | 6 +- .../connector-aliyun-dm/src/utils.test.ts | 6 +- .../connector-aliyun-sms/package.json | 5 +- .../connector-aliyun-sms/src/index.test.ts | 10 +- .../src/single-send-text.test.ts | 6 +- .../connector-aliyun-sms/src/utils.test.ts | 6 +- .../connectors/connector-apple/package.json | 5 +- .../connector-apple/src/index.test.ts | 28 +- .../connectors/connector-aws-ses/package.json | 5 +- .../connector-aws-ses/src/index.test.ts | 8 +- .../connectors/connector-azuread/package.json | 1 - .../connectors/connector-discord/package.json | 5 +- .../connector-discord/src/index.test.ts | 22 +- .../connector-facebook/package.json | 5 +- .../connector-facebook/src/index.test.ts | 30 +- .../connector-feishu-web/package.json | 5 +- .../connector-feishu-web/src/index.test.ts | 30 +- .../connectors/connector-github/package.json | 5 +- .../connector-github/src/index.test.ts | 30 +- .../connectors/connector-google/package.json | 5 +- .../connector-google/src/index.test.ts | 26 +- .../connectors/connector-kakao/package.json | 5 +- .../connector-kakao/src/index.test.ts | 26 +- .../connector-logto-email/package.json | 5 +- .../connector-logto-email/src/index.test.ts | 6 +- .../connector-logto-sms/package.json | 5 +- .../connector-logto-sms/src/index.test.ts | 4 +- .../connector-logto-social-demo/package.json | 5 +- .../src/index.test.ts | 6 +- .../connectors/connector-mailgun/package.json | 5 +- .../connector-mailgun/src/index.test.ts | 10 +- .../package.json | 5 +- .../connector-mock-email/package.json | 5 +- .../connector-mock-sms/package.json | 5 +- .../connector-mock-social/package.json | 5 +- .../connectors/connector-naver/package.json | 5 +- .../connector-naver/src/index.test.ts | 26 +- .../connectors/connector-oauth2/package.json | 5 +- .../connector-oauth2/src/index.test.ts | 12 +- .../connectors/connector-oidc/package.json | 5 +- .../connector-oidc/src/index.test.ts | 18 +- .../connectors/connector-saml/package.json | 5 +- .../connector-saml/src/index.test.ts | 18 +- .../connector-saml/src/utils.test.ts | 4 +- .../connector-sendgrid-email/package.json | 5 +- .../src/index.test.ts | 4 +- .../connectors/connector-smsaero/package.json | 5 +- .../connector-smsaero/src/index.test.ts | 4 +- .../connectors/connector-smtp/package.json | 5 +- .../connector-smtp/src/index.test.ts | 10 +- .../connector-tencent-sms/package.json | 5 +- .../connector-tencent-sms/src/index.test.ts | 12 +- .../connector-twilio-sms/package.json | 5 +- .../connector-twilio-sms/src/index.test.ts | 4 +- .../connector-wechat-native/package.json | 5 +- .../connector-wechat-native/src/index.test.ts | 32 +- .../connector-wechat-web/package.json | 5 +- .../connector-wechat-web/src/index.test.ts | 32 +- .../connectors/connector-wecom/package.json | 5 +- .../connector-wecom/src/index.test.ts | 32 +- packages/connectors/templates/package.json | 13 +- .../templates/preset/jest.config.js | 7 - .../connectors/templates/preset/tsconfig.json | 2 +- .../templates/preset/types/import-meta.d.ts | 10 - .../templates/preset/vitest.config.ts | 7 + packages/connectors/templates/sync-preset.js | 4 +- pnpm-lock.yaml | 713 ++++++++---------- 76 files changed, 634 insertions(+), 856 deletions(-) delete mode 100644 packages/connectors/templates/preset/jest.config.js delete mode 100644 packages/connectors/templates/preset/types/import-meta.d.ts create mode 100644 packages/connectors/templates/preset/vitest.config.ts diff --git a/packages/connectors/.gitignore b/packages/connectors/.gitignore index 35dfa630e..652458019 100644 --- a/packages/connectors/.gitignore +++ b/packages/connectors/.gitignore @@ -1,8 +1,7 @@ # generated files -/*/types /*/tsconfig.* -/*/jest.config.* /*/rollup.config.* +/*/vitest.config.* # keep templates !/templates/** diff --git a/packages/connectors/connector-alipay-native/package.json b/packages/connectors/connector-alipay-native/package.json index df22a902b..506a834bb 100644 --- a/packages/connectors/connector-alipay-native/package.json +++ b/packages/connectors/connector-alipay-native/package.json @@ -29,9 +29,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-alipay-native/src/index.test.ts b/packages/connectors/connector-alipay-native/src/index.test.ts index cee532872..634a41e6b 100644 --- a/packages/connectors/connector-alipay-native/src/index.test.ts +++ b/packages/connectors/connector-alipay-native/src/index.test.ts @@ -6,13 +6,11 @@ import { alipayEndpoint } from './constant.js'; import createConnector, { getAccessToken } from './index.js'; import { mockedAlipayNativeConfigWithValidPrivateKey } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedAlipayNativeConfigWithValidPrivateKey); +const getConfig = vi.fn().mockResolvedValue(mockedAlipayNativeConfigWithValidPrivateKey); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by state', async () => { @@ -26,7 +24,7 @@ describe('getAuthorizationUri', () => { jti: 'dummy-jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toBe('alipay://?app_id=2021000000000000&state=dummy-state'); }); @@ -35,7 +33,7 @@ describe('getAuthorizationUri', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const alipayEndpointUrl = new URL(alipayEndpoint); @@ -72,7 +70,7 @@ describe('getAccessToken', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({}, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({}, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, '{}') ); }); @@ -93,7 +91,7 @@ describe('getAccessToken', () => { }); await expect( getAccessToken('code', mockedAlipayNativeConfigWithValidPrivateKey) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); }); it('should fail with wrong code', async () => { @@ -110,7 +108,7 @@ describe('getAccessToken', () => { }); await expect( getAccessToken('wrong_code', mockedAlipayNativeConfigWithValidPrivateKey) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'Invalid code') ); }); @@ -136,7 +134,7 @@ describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const alipayEndpointUrl = new URL(alipayEndpoint); @@ -158,7 +156,7 @@ describe('getUserInfo', () => { const connector = await createConnector({ getConfig }); const { id, name, avatar, rawData } = await connector.getUserInfo( { auth_code: 'code' }, - jest.fn() + vi.fn() ); expect(id).toEqual('2088000000000000'); expect(name).toEqual('PlayboyEric'); @@ -189,9 +187,7 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect( - connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn()) - ).rejects.toMatchError( + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid, 'Invalid auth token') ); }); @@ -210,9 +206,7 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect( - connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn()) - ).rejects.toMatchError( + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'Invalid auth code') ); }); @@ -231,9 +225,7 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect( - connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn()) - ).rejects.toMatchError( + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'Invalid parameter', code: '40002', @@ -258,14 +250,14 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect( - connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn()) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.InvalidResponse)); + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toStrictEqual( + new ConnectorError(ConnectorErrorCodes.InvalidResponse) + ); }); it('should throw with other request errors', async () => { nock(alipayEndpointUrl.origin).post(alipayEndpointUrl.pathname).query(true).reply(500); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn())).rejects.toThrow(); + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-alipay-native/src/utils.test.ts b/packages/connectors/connector-alipay-native/src/utils.test.ts index 727f1d52c..053a18b82 100644 --- a/packages/connectors/connector-alipay-native/src/utils.test.ts +++ b/packages/connectors/connector-alipay-native/src/utils.test.ts @@ -5,14 +5,12 @@ import { } from './mock.js'; import { signingParameters } from './utils.js'; -const { jest } = import.meta; - -const listenJSONParse = jest.spyOn(JSON, 'parse'); -const listenJSONStringify = jest.spyOn(JSON, 'stringify'); +const listenJSONParse = vi.spyOn(JSON, 'parse'); +const listenJSONStringify = vi.spyOn(JSON, 'stringify'); describe('signingParameters', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); const testingParameters = { diff --git a/packages/connectors/connector-alipay-web/package.json b/packages/connectors/connector-alipay-web/package.json index b23babe62..2091c83eb 100644 --- a/packages/connectors/connector-alipay-web/package.json +++ b/packages/connectors/connector-alipay-web/package.json @@ -28,9 +28,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-alipay-web/src/index.test.ts b/packages/connectors/connector-alipay-web/src/index.test.ts index 6c7085488..caef90e61 100644 --- a/packages/connectors/connector-alipay-web/src/index.test.ts +++ b/packages/connectors/connector-alipay-web/src/index.test.ts @@ -6,13 +6,11 @@ import { alipayEndpoint, authorizationEndpoint } from './constant.js'; import createConnector, { getAccessToken } from './index.js'; import { mockedAlipayConfigWithValidPrivateKey } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedAlipayConfigWithValidPrivateKey); +const getConfig = vi.fn().mockResolvedValue(mockedAlipayConfigWithValidPrivateKey); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by redirectUri and state', async () => { @@ -26,7 +24,7 @@ describe('getAuthorizationUri', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?app_id=2021000000000000&redirect_uri=http%3A%2F%2Flocalhost%3A3001%2Fcallback&scope=auth_user&state=some_state` @@ -37,7 +35,7 @@ describe('getAuthorizationUri', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const alipayEndpointUrl = new URL(alipayEndpoint); @@ -78,7 +76,7 @@ describe('getAccessToken', () => { await expect( getAccessToken('code', mockedAlipayConfigWithValidPrivateKey) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); }); it('should fail with wrong code', async () => { @@ -96,7 +94,7 @@ describe('getAccessToken', () => { await expect( getAccessToken('wrong_code', mockedAlipayConfigWithValidPrivateKey) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'Invalid code') ); }); @@ -105,7 +103,7 @@ describe('getAccessToken', () => { describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); beforeEach(() => { @@ -144,7 +142,7 @@ describe('getUserInfo', () => { const connector = await createConnector({ getConfig }); const { id, name, avatar, rawData } = await connector.getUserInfo( { auth_code: 'code' }, - jest.fn() + vi.fn() ); expect(id).toEqual('2088000000000000'); expect(name).toEqual('PlayboyEric'); @@ -163,7 +161,7 @@ describe('getUserInfo', () => { it('throw General error if auth_code not provided in input', async () => { const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({}, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({}, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.InvalidResponse, '{}') ); }); @@ -182,9 +180,7 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect( - connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn()) - ).rejects.toMatchError( + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid, 'Invalid auth token') ); }); @@ -203,9 +199,7 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect( - connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn()) - ).rejects.toMatchError( + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'Invalid auth code') ); }); @@ -224,9 +218,7 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect( - connector.getUserInfo({ auth_code: 'wrong_code' }, jest.fn()) - ).rejects.toMatchError( + await expect(connector.getUserInfo({ auth_code: 'wrong_code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'Invalid parameter', code: '40002', @@ -251,7 +243,7 @@ describe('getUserInfo', () => { sign: '', }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ auth_code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ auth_code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.InvalidResponse) ); }); @@ -259,6 +251,6 @@ describe('getUserInfo', () => { it('should throw with other request errors', async () => { nock(alipayEndpointUrl.origin).post(alipayEndpointUrl.pathname).query(true).reply(500); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ auth_code: 'code' }, jest.fn())).rejects.toThrow(); + await expect(connector.getUserInfo({ auth_code: 'code' }, vi.fn())).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-alipay-web/src/utils.test.ts b/packages/connectors/connector-alipay-web/src/utils.test.ts index 1b4a3338c..a285af53f 100644 --- a/packages/connectors/connector-alipay-web/src/utils.test.ts +++ b/packages/connectors/connector-alipay-web/src/utils.test.ts @@ -2,14 +2,12 @@ import { methodForAccessToken } from './constant.js'; import { mockedAlipayConfigWithValidPrivateKey, mockedAlipayPublicParameters } from './mock.js'; import { signingParameters } from './utils.js'; -const { jest } = import.meta; - -const listenJSONParse = jest.spyOn(JSON, 'parse'); -const listenJSONStringify = jest.spyOn(JSON, 'stringify'); +const listenJSONParse = vi.spyOn(JSON, 'parse'); +const listenJSONStringify = vi.spyOn(JSON, 'stringify'); describe('signingParameters', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); const testingParameters = { diff --git a/packages/connectors/connector-aliyun-dm/package.json b/packages/connectors/connector-aliyun-dm/package.json index 1e8af3bbb..a9f1fc506 100644 --- a/packages/connectors/connector-aliyun-dm/package.json +++ b/packages/connectors/connector-aliyun-dm/package.json @@ -23,9 +23,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-aliyun-dm/src/index.test.ts b/packages/connectors/connector-aliyun-dm/src/index.test.ts index 9c8d0ea1a..89c6495f5 100644 --- a/packages/connectors/connector-aliyun-dm/src/index.test.ts +++ b/packages/connectors/connector-aliyun-dm/src/index.test.ts @@ -2,16 +2,14 @@ import { TemplateType } from '@logto/connector-kit'; import { mockedConfigWithAllRequiredTemplates } from './mock.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockedConfigWithAllRequiredTemplates); -const getConfig = jest.fn().mockResolvedValue(mockedConfigWithAllRequiredTemplates); - -const singleSendMail = jest.fn(() => ({ +const singleSendMail = vi.fn(() => ({ body: JSON.stringify({ EnvId: 'env-id', RequestId: 'request-id' }), statusCode: 200, })); -jest.unstable_mockModule('./single-send-mail.js', () => ({ +vi.mock('./single-send-mail.js', () => ({ singleSendMail, })); @@ -19,7 +17,7 @@ const { default: createConnector } = await import('./index.js'); describe('sendMessage()', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should call singleSendMail() with correct template and content', async () => { diff --git a/packages/connectors/connector-aliyun-dm/src/single-send-mail.test.ts b/packages/connectors/connector-aliyun-dm/src/single-send-mail.test.ts index 4804ad8e7..1162b5d32 100644 --- a/packages/connectors/connector-aliyun-dm/src/single-send-mail.test.ts +++ b/packages/connectors/connector-aliyun-dm/src/single-send-mail.test.ts @@ -1,8 +1,6 @@ -const { jest } = import.meta; +const request = vi.fn(); -const request = jest.fn(); - -jest.unstable_mockModule('./utils.js', () => ({ +vi.mock('./utils.js', () => ({ request, })); diff --git a/packages/connectors/connector-aliyun-dm/src/utils.test.ts b/packages/connectors/connector-aliyun-dm/src/utils.test.ts index 87d18dfad..24da02e7a 100644 --- a/packages/connectors/connector-aliyun-dm/src/utils.test.ts +++ b/packages/connectors/connector-aliyun-dm/src/utils.test.ts @@ -1,10 +1,8 @@ import { mockedParameters } from './mock.js'; -const { jest } = import.meta; +const post = vi.fn(); -const post = jest.fn(); - -jest.unstable_mockModule('got', () => ({ +vi.mock('got', () => ({ got: { post }, })); diff --git a/packages/connectors/connector-aliyun-sms/package.json b/packages/connectors/connector-aliyun-sms/package.json index 82f36fc3e..20bbc4a27 100644 --- a/packages/connectors/connector-aliyun-sms/package.json +++ b/packages/connectors/connector-aliyun-sms/package.json @@ -23,9 +23,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-aliyun-sms/src/index.test.ts b/packages/connectors/connector-aliyun-sms/src/index.test.ts index 10dba3ed0..bfbacf15b 100644 --- a/packages/connectors/connector-aliyun-sms/src/index.test.ts +++ b/packages/connectors/connector-aliyun-sms/src/index.test.ts @@ -2,16 +2,14 @@ import { TemplateType } from '@logto/connector-kit'; import { mockedConnectorConfig, phoneTest, codeTest } from './mock.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockedConnectorConfig); -const getConfig = jest.fn().mockResolvedValue(mockedConnectorConfig); - -const sendSms = jest.fn().mockResolvedValue({ +const sendSms = vi.fn().mockResolvedValue({ body: JSON.stringify({ Code: 'OK', RequestId: 'request-id', Message: 'OK' }), statusCode: 200, }); -jest.unstable_mockModule('./single-send-text.js', () => ({ +vi.mock('./single-send-text.js', () => ({ sendSms, })); @@ -19,7 +17,7 @@ const { default: createConnector } = await import('./index.js'); describe('sendMessage()', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should call singleSendMail() and replace code in content', async () => { diff --git a/packages/connectors/connector-aliyun-sms/src/single-send-text.test.ts b/packages/connectors/connector-aliyun-sms/src/single-send-text.test.ts index 64d269e98..ec7da9219 100644 --- a/packages/connectors/connector-aliyun-sms/src/single-send-text.test.ts +++ b/packages/connectors/connector-aliyun-sms/src/single-send-text.test.ts @@ -1,10 +1,8 @@ import { mockedRandomCode } from './mock.js'; -const { jest } = import.meta; +const request = vi.fn(); -const request = jest.fn(); - -jest.unstable_mockModule('./utils.js', () => ({ request })); +vi.mock('./utils.js', () => ({ request })); const { sendSms } = await import('./single-send-text.js'); diff --git a/packages/connectors/connector-aliyun-sms/src/utils.test.ts b/packages/connectors/connector-aliyun-sms/src/utils.test.ts index 87d18dfad..24da02e7a 100644 --- a/packages/connectors/connector-aliyun-sms/src/utils.test.ts +++ b/packages/connectors/connector-aliyun-sms/src/utils.test.ts @@ -1,10 +1,8 @@ import { mockedParameters } from './mock.js'; -const { jest } = import.meta; +const post = vi.fn(); -const post = jest.fn(); - -jest.unstable_mockModule('got', () => ({ +vi.mock('got', () => ({ got: { post }, })); diff --git a/packages/connectors/connector-apple/package.json b/packages/connectors/connector-apple/package.json index 084b811a1..dcb6b5732 100644 --- a/packages/connectors/connector-apple/package.json +++ b/packages/connectors/connector-apple/package.json @@ -25,9 +25,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-apple/src/index.test.ts b/packages/connectors/connector-apple/src/index.test.ts index 9e6f41c39..767133005 100644 --- a/packages/connectors/connector-apple/src/index.test.ts +++ b/packages/connectors/connector-apple/src/index.test.ts @@ -2,15 +2,13 @@ import { ConnectorError, ConnectorErrorCodes } from '@logto/connector-kit'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockedConfig); -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const jwtVerify = vi.fn(); -const jwtVerify = jest.fn(); - -jest.unstable_mockModule('jose', () => ({ +vi.mock('jose', () => ({ jwtVerify, - createRemoteJWKSet: jest.fn(), + createRemoteJWKSet: vi.fn(), })); const { authorizationEndpoint } = await import('./constant.js'); @@ -18,12 +16,12 @@ const { default: createConnector } = await import('./index.js'); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by redirectUri and state', async () => { const connector = await createConnector({ getConfig }); - const setSession = jest.fn(); + const setSession = vi.fn(); const authorizationUri = await connector.getAuthorizationUri( { state: 'some_state', @@ -50,7 +48,7 @@ describe('getAuthorizationUri', () => { describe('getUserInfo', () => { afterAll(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get user info from id token payload', async () => { @@ -59,7 +57,7 @@ describe('getUserInfo', () => { payload: { sub: userId, email: 'foo@bar.com', email_verified: true }, })); const connector = await createConnector({ getConfig }); - const userInfo = await connector.getUserInfo({ id_token: 'idToken' }, jest.fn()); + const userInfo = await connector.getUserInfo({ id_token: 'idToken' }, vi.fn()); expect(userInfo).toEqual({ id: userId, email: 'foo@bar.com', @@ -72,7 +70,7 @@ describe('getUserInfo', () => { payload: { sub: 'userId', email: 'foo@bar.com' }, })); const connector = await createConnector({ getConfig }); - const userInfo = await connector.getUserInfo({ id_token: 'idToken' }, jest.fn()); + const userInfo = await connector.getUserInfo({ id_token: 'idToken' }, vi.fn()); expect(userInfo).toEqual({ id: 'userId', rawData: { id_token: 'idToken' } }); }); @@ -90,7 +88,7 @@ describe('getUserInfo', () => { name: { firstName: 'foo', lastName: 'bar' }, }), }, - jest.fn() + vi.fn() ); // Should use info from `user` field first expect(userInfo).toEqual({ @@ -109,7 +107,7 @@ describe('getUserInfo', () => { it('should throw if id token is missing', async () => { const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({}, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({}, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, '{}') ); }); @@ -119,7 +117,7 @@ describe('getUserInfo', () => { throw new Error('jwtVerify failed'); }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ id_token: 'id_token' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ id_token: 'id_token' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialIdTokenInvalid) ); }); @@ -129,7 +127,7 @@ describe('getUserInfo', () => { payload: { iat: 123_456 }, })); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ id_token: 'id_token' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ id_token: 'id_token' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialIdTokenInvalid) ); }); diff --git a/packages/connectors/connector-aws-ses/package.json b/packages/connectors/connector-aws-ses/package.json index 558304d7b..955f6eafa 100644 --- a/packages/connectors/connector-aws-ses/package.json +++ b/packages/connectors/connector-aws-ses/package.json @@ -26,9 +26,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-aws-ses/src/index.test.ts b/packages/connectors/connector-aws-ses/src/index.test.ts index f95720a70..408b6de16 100644 --- a/packages/connectors/connector-aws-ses/src/index.test.ts +++ b/packages/connectors/connector-aws-ses/src/index.test.ts @@ -4,11 +4,9 @@ import { TemplateType } from '@logto/connector-kit'; import createConnector from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockedConfig); -const getConfig = jest.fn().mockResolvedValue(mockedConfig); - -jest.spyOn(SESv2Client.prototype, 'send').mockResolvedValue({ +vi.spyOn(SESv2Client.prototype, 'send').mockResolvedValue({ MessageId: 'mocked-message-id', $metadata: { httpStatusCode: 200, @@ -17,7 +15,7 @@ jest.spyOn(SESv2Client.prototype, 'send').mockResolvedValue({ describe('sendMessage()', () => { afterAll(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should call SendMail() with correct template and content', async () => { diff --git a/packages/connectors/connector-azuread/package.json b/packages/connectors/connector-azuread/package.json index 735b5016f..3f174bae6 100644 --- a/packages/connectors/connector-azuread/package.json +++ b/packages/connectors/connector-azuread/package.json @@ -25,7 +25,6 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", "test": "vitest src", "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" diff --git a/packages/connectors/connector-discord/package.json b/packages/connectors/connector-discord/package.json index 3cfe00c29..5813f8ba9 100644 --- a/packages/connectors/connector-discord/package.json +++ b/packages/connectors/connector-discord/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-discord/src/index.test.ts b/packages/connectors/connector-discord/src/index.test.ts index 333d0ff29..45664a11d 100644 --- a/packages/connectors/connector-discord/src/index.test.ts +++ b/packages/connectors/connector-discord/src/index.test.ts @@ -6,14 +6,12 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('Discord connector', () => { describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid authorizationUri with redirectUri and state', async () => { @@ -27,7 +25,7 @@ describe('Discord connector', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?client_id=%3Cclient-id%3E&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&scope=identify+email&state=some_state` @@ -38,7 +36,7 @@ describe('Discord connector', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get an accessToken by exchanging with code', async () => { @@ -66,7 +64,7 @@ describe('Discord connector', () => { await expect( getAccessToken(mockedConfig, { code: 'code', redirectUri: 'dummyRedirectUri' }) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); }); }); @@ -82,7 +80,7 @@ describe('Discord connector', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid SocialUserInfo', async () => { @@ -99,7 +97,7 @@ describe('Discord connector', () => { code: 'code', redirectUri: 'dummyRedirectUri', }, - jest.fn() + vi.fn() ); expect(socialUserInfo).toStrictEqual({ id: '1234567890', @@ -120,15 +118,15 @@ describe('Discord connector', () => { nock(userInfoEndpoint).get('').reply(401); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: 'dummyRedirectUri' }, jest.fn()) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); + connector.getUserInfo({ code: 'code', redirectUri: 'dummyRedirectUri' }, vi.fn()) + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); }); it('throws unrecognized error', async () => { nock(userInfoEndpoint).get('').reply(500); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: 'dummyRedirectUri' }, jest.fn()) + connector.getUserInfo({ code: 'code', redirectUri: 'dummyRedirectUri' }, vi.fn()) ).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-facebook/package.json b/packages/connectors/connector-facebook/package.json index ad43c9f85..c42c82717 100644 --- a/packages/connectors/connector-facebook/package.json +++ b/packages/connectors/connector-facebook/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-facebook/src/index.test.ts b/packages/connectors/connector-facebook/src/index.test.ts index 979fdf378..69df5e0d0 100644 --- a/packages/connectors/connector-facebook/src/index.test.ts +++ b/packages/connectors/connector-facebook/src/index.test.ts @@ -6,14 +6,12 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { clientId, clientSecret, code, dummyRedirectUri, fields, mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('Facebook connector', () => { describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid authorizationUri with redirectUri and state', async () => { @@ -29,7 +27,7 @@ describe('Facebook connector', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); const encodedRedirectUri = encodeURIComponent(redirectUri); @@ -42,7 +40,7 @@ describe('Facebook connector', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get an accessToken by exchanging with code', async () => { @@ -86,7 +84,7 @@ describe('Facebook connector', () => { await expect( getAccessToken(mockedConfig, { code, redirectUri: dummyRedirectUri }) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); }); }); @@ -110,7 +108,7 @@ describe('Facebook connector', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid SocialUserInfo', async () => { @@ -130,7 +128,7 @@ describe('Facebook connector', () => { code, redirectUri: dummyRedirectUri, }, - jest.fn() + vi.fn() ); expect(socialUserInfo).toStrictEqual({ id: '1234567890', @@ -150,8 +148,8 @@ describe('Facebook connector', () => { nock(userInfoEndpoint).get('').query({ fields }).reply(400); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code, redirectUri: dummyRedirectUri }, jest.fn()) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); + connector.getUserInfo({ code, redirectUri: dummyRedirectUri }, vi.fn()) + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); }); it('throws AuthorizationFailed error if error is access_denied', async () => { @@ -174,9 +172,9 @@ describe('Facebook connector', () => { error_description: 'Permissions error.', error_reason: 'user_denied', }, - jest.fn() + vi.fn() ) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.AuthorizationFailed, 'Permissions error.') ); }); @@ -201,9 +199,9 @@ describe('Facebook connector', () => { error_description: 'General error encountered.', error_reason: 'user_denied', }, - jest.fn() + vi.fn() ) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { error: 'general_error', error_code: 200, @@ -217,7 +215,7 @@ describe('Facebook connector', () => { nock(userInfoEndpoint).get('').reply(500); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code, redirectUri: dummyRedirectUri }, jest.fn()) + connector.getUserInfo({ code, redirectUri: dummyRedirectUri }, vi.fn()) ).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-feishu-web/package.json b/packages/connectors/connector-feishu-web/package.json index 1d552351d..f8a96c490 100644 --- a/packages/connectors/connector-feishu-web/package.json +++ b/packages/connectors/connector-feishu-web/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-feishu-web/src/index.test.ts b/packages/connectors/connector-feishu-web/src/index.test.ts index 118d31f9b..7a20668fc 100644 --- a/packages/connectors/connector-feishu-web/src/index.test.ts +++ b/packages/connectors/connector-feishu-web/src/index.test.ts @@ -6,13 +6,11 @@ import { accessTokenEndpoint, codeEndpoint, userInfoEndpoint } from './constant. import createConnector, { buildAuthorizationUri, getAccessToken } from './index.js'; import { mockedFeishuConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedFeishuConfig); +const getConfig = vi.fn().mockResolvedValue(mockedFeishuConfig); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should build authorization uri', function () { @@ -33,7 +31,7 @@ describe('getAuthorizationUri', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${codeEndpoint}?client_id=1112233&redirect_uri=http%3A%2F%2Flocalhost%3A3001%2Fcallback&response_type=code&state=some_state` @@ -44,7 +42,7 @@ describe('getAuthorizationUri', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const accessTokenUrl = new URL(accessTokenEndpoint); @@ -73,7 +71,7 @@ describe('getAccessToken', () => { await expect( getAccessToken('code', '123', '123', 'http://localhost:3000') - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'access_token is empty') ); }); @@ -86,7 +84,7 @@ describe('getAccessToken', () => { await expect( getAccessToken('code', '123', '123', 'http://localhost:3000') - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'invalid code') ); }); @@ -95,7 +93,7 @@ describe('getAccessToken', () => { describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); beforeEach(() => { @@ -137,7 +135,7 @@ describe('getUserInfo', () => { code: 'code', redirectUri: 'http://localhost:3000', }, - jest.fn() + vi.fn() ); expect(id).toEqual('ou_caecc734c2e3328a62489fe0648c4b98779515d3'); expect(name).toEqual('李雷'); @@ -147,7 +145,7 @@ describe('getUserInfo', () => { it('throw General error if code not provided in input', async () => { const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({}, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({}, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.InvalidResponse, '{}') ); }); @@ -159,8 +157,8 @@ describe('getUserInfo', () => { }); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'error_code', redirectUri: 'http://localhost:3000' }, jest.fn()) - ).rejects.toMatchError( + connector.getUserInfo({ code: 'error_code', redirectUri: 'http://localhost:3000' }, vi.fn()) + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid, 'invalid access token') ); }); @@ -171,8 +169,8 @@ describe('getUserInfo', () => { }); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: 'http://localhost:3000' }, jest.fn()) - ).rejects.toMatchError( + connector.getUserInfo({ code: 'code', redirectUri: 'http://localhost:3000' }, vi.fn()) + ).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.InvalidResponse, 'invalid user response') ); }); @@ -181,7 +179,7 @@ describe('getUserInfo', () => { nock(userInfoUrl.origin).get(userInfoUrl.pathname).query(true).reply(500); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: 'http://localhost:3000' }, jest.fn()) + connector.getUserInfo({ code: 'code', redirectUri: 'http://localhost:3000' }, vi.fn()) ).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-github/package.json b/packages/connectors/connector-github/package.json index 63295f5c4..e002f9a4f 100644 --- a/packages/connectors/connector-github/package.json +++ b/packages/connectors/connector-github/package.json @@ -25,9 +25,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-github/src/index.test.ts b/packages/connectors/connector-github/src/index.test.ts index 24c2b67dd..0656245e0 100644 --- a/packages/connectors/connector-github/src/index.test.ts +++ b/packages/connectors/connector-github/src/index.test.ts @@ -7,13 +7,11 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by redirectUri and state', async () => { @@ -27,7 +25,7 @@ describe('getAuthorizationUri', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?client_id=%3Cclient-id%3E&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&state=some_state&scope=read%3Auser` @@ -38,7 +36,7 @@ describe('getAuthorizationUri', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get an accessToken by exchanging with code', async () => { @@ -60,7 +58,7 @@ describe('getAccessToken', () => { nock(accessTokenEndpoint) .post('') .reply(200, qs.stringify({ access_token: '', scope: 'scope', token_type: 'token_type' })); - await expect(getAccessToken(mockedConfig, { code: 'code' })).rejects.toMatchError( + await expect(getAccessToken(mockedConfig, { code: 'code' })).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid) ); }); @@ -82,7 +80,7 @@ describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid SocialUserInfo', async () => { @@ -94,7 +92,7 @@ describe('getUserInfo', () => { foo: 'bar', }); const connector = await createConnector({ getConfig }); - const socialUserInfo = await connector.getUserInfo({ code: 'code' }, jest.fn()); + const socialUserInfo = await connector.getUserInfo({ code: 'code' }, vi.fn()); expect(socialUserInfo).toStrictEqual({ id: '1', avatar: 'https://github.com/images/error/octocat_happy.gif', @@ -118,7 +116,7 @@ describe('getUserInfo', () => { email: null, }); const connector = await createConnector({ getConfig }); - const socialUserInfo = await connector.getUserInfo({ code: 'code' }, jest.fn()); + const socialUserInfo = await connector.getUserInfo({ code: 'code' }, vi.fn()); expect(socialUserInfo).toMatchObject({ id: '1', rawData: { @@ -133,7 +131,7 @@ describe('getUserInfo', () => { it('throws SocialAccessTokenInvalid error if remote response code is 401', async () => { nock(userInfoEndpoint).get('').reply(401); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid) ); }); @@ -154,9 +152,9 @@ describe('getUserInfo', () => { error_uri: 'https://docs.github.com/apps/troubleshooting-authorization-request-errors#access-denied', }, - jest.fn() + vi.fn() ) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError( ConnectorErrorCodes.AuthorizationFailed, 'The user has denied your application access.' @@ -178,9 +176,9 @@ describe('getUserInfo', () => { error: 'general_error', error_description: 'General error encountered.', }, - jest.fn() + vi.fn() ) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError( ConnectorErrorCodes.General, '{"error":"general_error","error_description":"General error encountered."}' @@ -191,6 +189,6 @@ describe('getUserInfo', () => { it('throws unrecognized error', async () => { nock(userInfoEndpoint).get('').reply(500); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toThrow(); + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-google/package.json b/packages/connectors/connector-google/package.json index 2148928fb..f7223b541 100644 --- a/packages/connectors/connector-google/package.json +++ b/packages/connectors/connector-google/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-google/src/index.test.ts b/packages/connectors/connector-google/src/index.test.ts index 32d2ed09f..4b258f021 100644 --- a/packages/connectors/connector-google/src/index.test.ts +++ b/packages/connectors/connector-google/src/index.test.ts @@ -6,14 +6,12 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('google connector', () => { describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid authorizationUri with redirectUri and state', async () => { @@ -27,7 +25,7 @@ describe('google connector', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?client_id=%3Cclient-id%3E&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&state=some_state&scope=openid+profile+email` @@ -38,7 +36,7 @@ describe('google connector', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get an accessToken by exchanging with code', async () => { @@ -60,7 +58,7 @@ describe('google connector', () => { .reply(200, { access_token: '', scope: 'scope', token_type: 'token_type' }); await expect( getAccessToken(mockedConfig, { code: 'code', redirectUri: 'dummyRedirectUri' }) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); }); }); @@ -75,7 +73,7 @@ describe('google connector', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid SocialUserInfo', async () => { @@ -96,7 +94,7 @@ describe('google connector', () => { code: 'code', redirectUri: 'redirectUri', }, - jest.fn() + vi.fn() ); expect(socialUserInfo).toStrictEqual({ id: '1234567890', @@ -111,8 +109,8 @@ describe('google connector', () => { nock(userInfoEndpoint).post('').reply(401); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: '' }, jest.fn()) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); + connector.getUserInfo({ code: 'code', redirectUri: '' }, vi.fn()) + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); }); it('throws General error', async () => { @@ -133,9 +131,9 @@ describe('google connector', () => { error: 'general_error', error_description: 'General error encountered.', }, - jest.fn() + vi.fn() ) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError( ConnectorErrorCodes.General, '{"error":"general_error","error_description":"General error encountered."}' @@ -147,7 +145,7 @@ describe('google connector', () => { nock(userInfoEndpoint).post('').reply(500); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: '' }, jest.fn()) + connector.getUserInfo({ code: 'code', redirectUri: '' }, vi.fn()) ).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-kakao/package.json b/packages/connectors/connector-kakao/package.json index 6da7db82f..10d873a89 100644 --- a/packages/connectors/connector-kakao/package.json +++ b/packages/connectors/connector-kakao/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-kakao/src/index.test.ts b/packages/connectors/connector-kakao/src/index.test.ts index 682e0e0a8..830897ebd 100644 --- a/packages/connectors/connector-kakao/src/index.test.ts +++ b/packages/connectors/connector-kakao/src/index.test.ts @@ -6,14 +6,12 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('kakao connector', () => { describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid authorizationUri with redirectUri and state', async () => { @@ -27,7 +25,7 @@ describe('kakao connector', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?client_id=%3Cclient-id%3E&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&state=some_state` @@ -38,7 +36,7 @@ describe('kakao connector', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get an accessToken by exchanging with code', async () => { @@ -60,7 +58,7 @@ describe('kakao connector', () => { .reply(200, { access_token: '', scope: 'scope', token_type: 'token_type' }); await expect( getAccessToken(mockedConfig, { code: 'code', redirectUri: 'dummyRedirectUri' }) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); }); }); @@ -75,7 +73,7 @@ describe('kakao connector', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid SocialUserInfo', async () => { @@ -98,7 +96,7 @@ describe('kakao connector', () => { code: 'code', redirectUri: 'redirectUri', }, - jest.fn() + vi.fn() ); expect(socialUserInfo).toStrictEqual({ id: '1234567890', @@ -113,8 +111,8 @@ describe('kakao connector', () => { nock(userInfoEndpoint).post('').reply(401); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: '' }, jest.fn()) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); + connector.getUserInfo({ code: 'code', redirectUri: '' }, vi.fn()) + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); }); it('throws General error', async () => { @@ -135,9 +133,9 @@ describe('kakao connector', () => { error: 'general_error', error_description: 'General error encountered.', }, - jest.fn() + vi.fn() ) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError( ConnectorErrorCodes.General, '{"error":"general_error","error_description":"General error encountered."}' @@ -149,7 +147,7 @@ describe('kakao connector', () => { nock(userInfoEndpoint).post('').reply(500); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: '' }, jest.fn()) + connector.getUserInfo({ code: 'code', redirectUri: '' }, vi.fn()) ).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-logto-email/package.json b/packages/connectors/connector-logto-email/package.json index d95b01210..c1af55689 100644 --- a/packages/connectors/connector-logto-email/package.json +++ b/packages/connectors/connector-logto-email/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-logto-email/src/index.test.ts b/packages/connectors/connector-logto-email/src/index.test.ts index e38af0d89..084e46110 100644 --- a/packages/connectors/connector-logto-email/src/index.test.ts +++ b/packages/connectors/connector-logto-email/src/index.test.ts @@ -6,16 +6,14 @@ import { TemplateType } from '@logto/connector-kit'; import { emailEndpoint, usageEndpoint } from './constant.js'; import createConnector from './index.js'; -const { jest } = import.meta; - const endpoint = 'http://localhost:3003'; const api = got.extend({ prefixUrl: endpoint }); const dropLeadingSlash = (path: string) => path.replace(/^\//, ''); const buildUrl = (path: string, endpoint: string) => new URL(`${endpoint}/api${path}`); -const getConfig = jest.fn().mockResolvedValue({}); -const getCloudServiceClient = jest.fn().mockResolvedValue({ +const getConfig = vi.fn().mockResolvedValue({}); +const getCloudServiceClient = vi.fn().mockResolvedValue({ post: async (path: string, payload: { body: unknown }) => { return api(dropLeadingSlash(path), { method: 'POST', diff --git a/packages/connectors/connector-logto-sms/package.json b/packages/connectors/connector-logto-sms/package.json index 6113e8b02..fd752400c 100644 --- a/packages/connectors/connector-logto-sms/package.json +++ b/packages/connectors/connector-logto-sms/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-logto-sms/src/index.test.ts b/packages/connectors/connector-logto-sms/src/index.test.ts index 740d7b34f..95d1ed10e 100644 --- a/packages/connectors/connector-logto-sms/src/index.test.ts +++ b/packages/connectors/connector-logto-sms/src/index.test.ts @@ -5,9 +5,7 @@ import { TemplateType } from '@logto/connector-kit'; import { smsEndpoint } from './constant.js'; import { mockedAccessTokenResponse, mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); const { default: createConnector } = await import('./index.js'); diff --git a/packages/connectors/connector-logto-social-demo/package.json b/packages/connectors/connector-logto-social-demo/package.json index 8fdd84958..5c841418c 100644 --- a/packages/connectors/connector-logto-social-demo/package.json +++ b/packages/connectors/connector-logto-social-demo/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-logto-social-demo/src/index.test.ts b/packages/connectors/connector-logto-social-demo/src/index.test.ts index 63aaf3990..0bce8984e 100644 --- a/packages/connectors/connector-logto-social-demo/src/index.test.ts +++ b/packages/connectors/connector-logto-social-demo/src/index.test.ts @@ -2,14 +2,12 @@ import createConnector from './index.js'; import type { SocialDemoConfig } from './types.js'; import { SocialProvider } from './types.js'; -const { jest } = import.meta; - const mockedConfig: SocialDemoConfig = { provider: SocialProvider.GitHub, clientId: 'client-id', redirectUri: 'http://localhost:3000/callback', }; -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('getAuthorizationUri', () => { it('should get a valid uri by redirectUri and state', async () => { @@ -23,7 +21,7 @@ describe('getAuthorizationUri', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toContain(encodeURIComponent(mockedConfig.redirectUri)); expect(authorizationUri).toContain( diff --git a/packages/connectors/connector-mailgun/package.json b/packages/connectors/connector-mailgun/package.json index af66a5b23..ba3de69fd 100644 --- a/packages/connectors/connector-mailgun/package.json +++ b/packages/connectors/connector-mailgun/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-mailgun/src/index.test.ts b/packages/connectors/connector-mailgun/src/index.test.ts index 50468ce53..ac1b4d034 100644 --- a/packages/connectors/connector-mailgun/src/index.test.ts +++ b/packages/connectors/connector-mailgun/src/index.test.ts @@ -5,9 +5,7 @@ import { TemplateType } from '@logto/connector-kit'; import createMailgunConnector from './index.js'; import { type MailgunConfig } from './types.js'; -const { jest } = import.meta; - -const getConfig = jest.fn(); +const getConfig = vi.fn(); const domain = 'example.com'; const apiKey = 'apiKey'; @@ -210,7 +208,7 @@ describe('Maligun connector', () => { code: '123456', }, }) - ).rejects.toThrowErrorMatchingInlineSnapshot('"ConnectorError: template_not_found"'); + ).rejects.toThrowErrorMatchingInlineSnapshot('[Error: ConnectorError: template_not_found]'); await expect( connector.sendMessage({ @@ -221,7 +219,7 @@ describe('Maligun connector', () => { code: '123456', }, }) - ).rejects.toThrowErrorMatchingInlineSnapshot('"ConnectorError: template_not_found"'); + ).rejects.toThrowErrorMatchingInlineSnapshot('[Error: ConnectorError: template_not_found]'); }); it('should throw error if mailgun returns error', async () => { @@ -247,7 +245,7 @@ describe('Maligun connector', () => { }, }) ).rejects.toThrowErrorMatchingInlineSnapshot( - '"ConnectorError: {"statusCode":400,"body":"{\\"message\\":\\"error\\"}"}"' + '[Error: ConnectorError: {"statusCode":400,"body":"{\\"message\\":\\"error\\"}"}]' ); }); }); diff --git a/packages/connectors/connector-mock-email-alternative/package.json b/packages/connectors/connector-mock-email-alternative/package.json index 63fa84fd9..19e72313d 100644 --- a/packages/connectors/connector-mock-email-alternative/package.json +++ b/packages/connectors/connector-mock-email-alternative/package.json @@ -13,9 +13,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "main": "./lib/index.js", diff --git a/packages/connectors/connector-mock-email/package.json b/packages/connectors/connector-mock-email/package.json index 96e5f94c2..bf8101d55 100644 --- a/packages/connectors/connector-mock-email/package.json +++ b/packages/connectors/connector-mock-email/package.json @@ -13,9 +13,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "main": "./lib/index.js", diff --git a/packages/connectors/connector-mock-sms/package.json b/packages/connectors/connector-mock-sms/package.json index 9678d8e70..208614b2e 100644 --- a/packages/connectors/connector-mock-sms/package.json +++ b/packages/connectors/connector-mock-sms/package.json @@ -13,9 +13,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "main": "./lib/index.js", diff --git a/packages/connectors/connector-mock-social/package.json b/packages/connectors/connector-mock-social/package.json index 1b49bbaf6..458043e2b 100644 --- a/packages/connectors/connector-mock-social/package.json +++ b/packages/connectors/connector-mock-social/package.json @@ -13,9 +13,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "main": "./lib/index.js", diff --git a/packages/connectors/connector-naver/package.json b/packages/connectors/connector-naver/package.json index 66154e9c5..44d8b28e3 100644 --- a/packages/connectors/connector-naver/package.json +++ b/packages/connectors/connector-naver/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-naver/src/index.test.ts b/packages/connectors/connector-naver/src/index.test.ts index 18b8c656a..03268914c 100644 --- a/packages/connectors/connector-naver/src/index.test.ts +++ b/packages/connectors/connector-naver/src/index.test.ts @@ -6,14 +6,12 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('naver connector', () => { describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid authorizationUri with redirectUri and state', async () => { @@ -27,7 +25,7 @@ describe('naver connector', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?client_id=%3Cclient-id%3E&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&state=some_state` @@ -38,7 +36,7 @@ describe('naver connector', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get an accessToken by exchanging with code', async () => { @@ -60,7 +58,7 @@ describe('naver connector', () => { .reply(200, { access_token: '', scope: 'scope', token_type: 'token_type' }); await expect( getAccessToken(mockedConfig, { code: 'code', redirectUri: 'dummyRedirectUri' }) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid)); }); }); @@ -75,7 +73,7 @@ describe('naver connector', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid SocialUserInfo', async () => { @@ -100,7 +98,7 @@ describe('naver connector', () => { code: 'code', redirectUri: 'redirectUri', }, - jest.fn() + vi.fn() ); expect(socialUserInfo).toMatchObject({ id: '32742776', @@ -115,8 +113,8 @@ describe('naver connector', () => { nock(userInfoEndpoint).post('').reply(401); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: '' }, jest.fn()) - ).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); + connector.getUserInfo({ code: 'code', redirectUri: '' }, vi.fn()) + ).rejects.toStrictEqual(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)); }); it('throws General error', async () => { @@ -137,9 +135,9 @@ describe('naver connector', () => { error: 'general_error', error_description: 'General error encountered.', }, - jest.fn() + vi.fn() ) - ).rejects.toMatchError( + ).rejects.toStrictEqual( new ConnectorError( ConnectorErrorCodes.General, '{"error":"general_error","error_description":"General error encountered."}' @@ -151,7 +149,7 @@ describe('naver connector', () => { nock(userInfoEndpoint).post('').reply(500); const connector = await createConnector({ getConfig }); await expect( - connector.getUserInfo({ code: 'code', redirectUri: '' }, jest.fn()) + connector.getUserInfo({ code: 'code', redirectUri: '' }, vi.fn()) ).rejects.toThrow(); }); }); diff --git a/packages/connectors/connector-oauth2/package.json b/packages/connectors/connector-oauth2/package.json index eaa3cec19..d50de06c6 100644 --- a/packages/connectors/connector-oauth2/package.json +++ b/packages/connectors/connector-oauth2/package.json @@ -25,9 +25,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-oauth2/src/index.test.ts b/packages/connectors/connector-oauth2/src/index.test.ts index d490cbe29..e242fe579 100644 --- a/packages/connectors/connector-oauth2/src/index.test.ts +++ b/packages/connectors/connector-oauth2/src/index.test.ts @@ -2,20 +2,18 @@ import nock from 'nock'; import { mockConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockConfig); +const getConfig = vi.fn().mockResolvedValue(mockConfig); const { default: createConnector } = await import('./index.js'); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by redirectUri and state', async () => { const connector = await createConnector({ getConfig }); - const setSession = jest.fn(); + const setSession = vi.fn(); const authorizationUri = await connector.getAuthorizationUri( { state: 'some_state', @@ -40,7 +38,7 @@ describe('getAuthorizationUri', () => { describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid userInfo', async () => { @@ -64,7 +62,7 @@ describe('getUserInfo', () => { const connector = await createConnector({ getConfig }); const userInfo = await connector.getUserInfo( { code: 'code' }, - jest.fn().mockImplementationOnce(() => { + vi.fn().mockImplementationOnce(() => { return { redirectUri: 'http://localhost:3001/callback' }; }) ); diff --git a/packages/connectors/connector-oidc/package.json b/packages/connectors/connector-oidc/package.json index f84a7b44c..596488533 100644 --- a/packages/connectors/connector-oidc/package.json +++ b/packages/connectors/connector-oidc/package.json @@ -26,9 +26,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-oidc/src/index.test.ts b/packages/connectors/connector-oidc/src/index.test.ts index d064f08bf..b54bc311f 100644 --- a/packages/connectors/connector-oidc/src/index.test.ts +++ b/packages/connectors/connector-oidc/src/index.test.ts @@ -2,22 +2,20 @@ import nock from 'nock'; import { mockConfig } from './mock.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockConfig); -const getConfig = jest.fn().mockResolvedValue(mockConfig); +const jwtVerify = vi.fn(); -const jwtVerify = jest.fn(); - -jest.unstable_mockModule('jose', () => ({ +vi.mock('jose', () => ({ jwtVerify, - createRemoteJWKSet: jest.fn(), + createRemoteJWKSet: vi.fn(), })); const { default: createConnector } = await import('./index.js'); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by redirectUri and state', async () => { @@ -31,7 +29,7 @@ describe('getAuthorizationUri', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); const { origin, pathname, searchParams } = new URL(authorizationUri); @@ -48,7 +46,7 @@ describe('getAuthorizationUri', () => { describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get valid userInfo', async () => { @@ -65,7 +63,7 @@ describe('getUserInfo', () => { const connector = await createConnector({ getConfig }); const userInfo = await connector.getUserInfo( { code: 'code' }, - jest.fn().mockImplementationOnce(() => { + vi.fn().mockImplementationOnce(() => { return { nonce: 'nonce', redirectUri: 'http://localhost:3001/callback' }; }) ); diff --git a/packages/connectors/connector-saml/package.json b/packages/connectors/connector-saml/package.json index aa92eec85..7121deddf 100644 --- a/packages/connectors/connector-saml/package.json +++ b/packages/connectors/connector-saml/package.json @@ -26,9 +26,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-saml/src/index.test.ts b/packages/connectors/connector-saml/src/index.test.ts index 1f564dd2d..289af1878 100644 --- a/packages/connectors/connector-saml/src/index.test.ts +++ b/packages/connectors/connector-saml/src/index.test.ts @@ -1,18 +1,16 @@ import createConnector, { validateSamlAssertion } from './index.js'; import { mockAttributes, mockedConfig, mockSamlResponse } from './mock.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockedConfig); -const getConfig = jest.fn().mockResolvedValue(mockedConfig); - -const setSession = jest.fn(); -const getSession = jest.fn(); +const setSession = vi.fn(); +const getSession = vi.fn(); const connector = await createConnector({ getConfig }); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri and save required information to storage', async () => { @@ -39,11 +37,11 @@ describe('getAuthorizationUri', () => { describe('validateSamlAssertion', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('Should return right redirectUri', async () => { - jest.useFakeTimers().setSystemTime(new Date('2023-01-18T14:55:45.406Z')); + vi.useFakeTimers().setSystemTime(new Date('2023-01-18T14:55:45.406Z')); getSession.mockResolvedValue({ connectorFactoryId: 'saml', state: 'some_state', @@ -61,13 +59,13 @@ describe('validateSamlAssertion', () => { ); expect(setSession).toHaveBeenCalledWith(expect.anything()); expect(redirectUri).toEqual('http://localhost:3000/callback?state=some_state'); - jest.useRealTimers(); + vi.useRealTimers(); }); }); describe('getUserInfo', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('get right profile', async () => { diff --git a/packages/connectors/connector-saml/src/utils.test.ts b/packages/connectors/connector-saml/src/utils.test.ts index 828471f1e..5b9ef7a73 100644 --- a/packages/connectors/connector-saml/src/utils.test.ts +++ b/packages/connectors/connector-saml/src/utils.test.ts @@ -1,10 +1,8 @@ import { userProfileMapping } from './utils.js'; -const { jest } = import.meta; - describe('userProfileMapping', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should return right user profile', () => { diff --git a/packages/connectors/connector-sendgrid-email/package.json b/packages/connectors/connector-sendgrid-email/package.json index 2f7650c70..260421895 100644 --- a/packages/connectors/connector-sendgrid-email/package.json +++ b/packages/connectors/connector-sendgrid-email/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-sendgrid-email/src/index.test.ts b/packages/connectors/connector-sendgrid-email/src/index.test.ts index 9f518865c..1062b2159 100644 --- a/packages/connectors/connector-sendgrid-email/src/index.test.ts +++ b/packages/connectors/connector-sendgrid-email/src/index.test.ts @@ -1,9 +1,7 @@ import createConnector from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('SendGrid connector', () => { it('init without throwing errors', async () => { diff --git a/packages/connectors/connector-smsaero/package.json b/packages/connectors/connector-smsaero/package.json index 2465fdefe..e894530d5 100644 --- a/packages/connectors/connector-smsaero/package.json +++ b/packages/connectors/connector-smsaero/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-smsaero/src/index.test.ts b/packages/connectors/connector-smsaero/src/index.test.ts index 253b7ada7..dd1e57945 100644 --- a/packages/connectors/connector-smsaero/src/index.test.ts +++ b/packages/connectors/connector-smsaero/src/index.test.ts @@ -1,9 +1,7 @@ import createConnector from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('SMSAero SMS connector', () => { it('init without throwing errors', async () => { diff --git a/packages/connectors/connector-smtp/package.json b/packages/connectors/connector-smtp/package.json index 0cf61efa8..f413033f9 100644 --- a/packages/connectors/connector-smtp/package.json +++ b/packages/connectors/connector-smtp/package.json @@ -28,9 +28,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-smtp/src/index.test.ts b/packages/connectors/connector-smtp/src/index.test.ts index ad4426045..a28137dd3 100644 --- a/packages/connectors/connector-smtp/src/index.test.ts +++ b/packages/connectors/connector-smtp/src/index.test.ts @@ -16,18 +16,16 @@ import { } from './mock.js'; import { smtpConfigGuard } from './types.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockedConfig); -const getConfig = jest.fn().mockResolvedValue(mockedConfig); - -const sendMail = jest.fn(); +const sendMail = vi.fn(); // @ts-expect-error for testing -jest.spyOn(nodemailer, 'createTransport').mockReturnValue({ sendMail } as Transporter); +vi.spyOn(nodemailer, 'createTransport').mockReturnValue({ sendMail } as Transporter); describe('SMTP connector', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('init without throwing errors', async () => { diff --git a/packages/connectors/connector-tencent-sms/package.json b/packages/connectors/connector-tencent-sms/package.json index 9f0b2ef41..921b29b49 100644 --- a/packages/connectors/connector-tencent-sms/package.json +++ b/packages/connectors/connector-tencent-sms/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-tencent-sms/src/index.test.ts b/packages/connectors/connector-tencent-sms/src/index.test.ts index a30b51fed..06e60445a 100644 --- a/packages/connectors/connector-tencent-sms/src/index.test.ts +++ b/packages/connectors/connector-tencent-sms/src/index.test.ts @@ -2,11 +2,9 @@ import { TemplateType } from '@logto/connector-kit'; import { codeTest, mockedConnectorConfig, mockedTemplateCode, phoneTest } from './mock.js'; -const { jest } = import.meta; +const getConfig = vi.fn().mockResolvedValue(mockedConnectorConfig); -const getConfig = jest.fn().mockResolvedValue(mockedConnectorConfig); - -const sendSmsRequest = jest.fn(() => { +const sendSmsRequest = vi.fn(() => { return { body: { Response: { @@ -27,10 +25,10 @@ const sendSmsRequest = jest.fn(() => { }; }); -jest.unstable_mockModule('./http.js', () => { +vi.mock('./http.js', () => { return { sendSmsRequest, - isSmsErrorResponse: jest.fn((response) => { + isSmsErrorResponse: vi.fn((response) => { return response.Response.Error !== undefined; }), }; @@ -40,7 +38,7 @@ const { default: createConnector } = await import('./index.js'); describe('sendMessage()', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should call sendSmsRequest() and replace code in content', async () => { diff --git a/packages/connectors/connector-twilio-sms/package.json b/packages/connectors/connector-twilio-sms/package.json index 3fc3c5c66..d694aa060 100644 --- a/packages/connectors/connector-twilio-sms/package.json +++ b/packages/connectors/connector-twilio-sms/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-twilio-sms/src/index.test.ts b/packages/connectors/connector-twilio-sms/src/index.test.ts index f7f61febb..937403c0f 100644 --- a/packages/connectors/connector-twilio-sms/src/index.test.ts +++ b/packages/connectors/connector-twilio-sms/src/index.test.ts @@ -1,9 +1,7 @@ import createConnector from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('Twilio SMS connector', () => { it('init without throwing errors', async () => { diff --git a/packages/connectors/connector-wechat-native/package.json b/packages/connectors/connector-wechat-native/package.json index 6a9e9986e..8d94b5d07 100644 --- a/packages/connectors/connector-wechat-native/package.json +++ b/packages/connectors/connector-wechat-native/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-wechat-native/src/index.test.ts b/packages/connectors/connector-wechat-native/src/index.test.ts index 94dfcbdaa..b4bde0fb2 100644 --- a/packages/connectors/connector-wechat-native/src/index.test.ts +++ b/packages/connectors/connector-wechat-native/src/index.test.ts @@ -6,13 +6,11 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri', async () => { @@ -26,7 +24,7 @@ describe('getAuthorizationUri', () => { jti: 'dummy-jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?app_id=%3Capp-id%3E&state=dummy-state` @@ -37,7 +35,7 @@ describe('getAuthorizationUri', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const accessTokenEndpointUrl = new URL(accessTokenEndpoint); @@ -66,7 +64,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(parameters) .reply(200, { errcode: 40_029, errmsg: 'invalid code' }); - await expect(getAccessToken('code', mockedConfig)).rejects.toMatchError( + await expect(getAccessToken('code', mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'invalid code') ); }); @@ -76,7 +74,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(true) .reply(200, { errcode: 40_163, errmsg: 'code been used' }); - await expect(getAccessToken('code', mockedConfig)).rejects.toMatchError( + await expect(getAccessToken('code', mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'code been used') ); }); @@ -86,7 +84,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(true) .reply(200, { errcode: -1, errmsg: 'system error' }); - await expect(getAccessToken('wrong_code', mockedConfig)).rejects.toMatchError( + await expect(getAccessToken('wrong_code', mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'system error', errcode: -1, @@ -132,7 +130,7 @@ describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const userInfoEndpointUrl = new URL(userInfoEndpoint); @@ -149,7 +147,7 @@ describe('getUserInfo', () => { .query(parameters) .reply(0, jsonResponse); const connector = await createConnector({ getConfig }); - const socialUserInfo = await connector.getUserInfo({ code: 'code' }, jest.fn()); + const socialUserInfo = await connector.getUserInfo({ code: 'code' }, vi.fn()); expect(socialUserInfo).toMatchObject({ id: 'this_is_an_arbitrary_wechat_union_id', avatar: 'https://github.com/images/error/octocat_happy.gif', @@ -160,7 +158,7 @@ describe('getUserInfo', () => { it('throws General error if code not provided in input', async () => { const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({}, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({}, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, '{}') ); }); @@ -175,7 +173,7 @@ describe('getUserInfo', () => { errmsg: 'missing openid', }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'missing openid', errcode: 41_009, @@ -189,7 +187,7 @@ describe('getUserInfo', () => { .query(parameters) .reply(200, { errcode: 40_001, errmsg: 'invalid credential' }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid, 'invalid credential') ); }); @@ -197,7 +195,7 @@ describe('getUserInfo', () => { it('throws unrecognized error', async () => { nock(userInfoEndpointUrl.origin).get(userInfoEndpointUrl.pathname).query(parameters).reply(500); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toThrow(); + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toThrow(); }); it('throws Error if request failed and errcode is not 40001', async () => { @@ -206,7 +204,7 @@ describe('getUserInfo', () => { .query(parameters) .reply(200, { errcode: 40_003, errmsg: 'invalid openid' }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'invalid openid', errcode: 40_003, @@ -217,7 +215,7 @@ describe('getUserInfo', () => { it('throws SocialAccessTokenInvalid error if response code is 401', async () => { nock(userInfoEndpointUrl.origin).get(userInfoEndpointUrl.pathname).query(parameters).reply(401); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid) ); }); diff --git a/packages/connectors/connector-wechat-web/package.json b/packages/connectors/connector-wechat-web/package.json index e05743e91..f0b1b087e 100644 --- a/packages/connectors/connector-wechat-web/package.json +++ b/packages/connectors/connector-wechat-web/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-wechat-web/src/index.test.ts b/packages/connectors/connector-wechat-web/src/index.test.ts index f43a84a6f..3906fed7e 100644 --- a/packages/connectors/connector-wechat-web/src/index.test.ts +++ b/packages/connectors/connector-wechat-web/src/index.test.ts @@ -6,13 +6,11 @@ import { accessTokenEndpoint, authorizationEndpoint, userInfoEndpoint } from './ import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by redirectUri and state', async () => { @@ -26,7 +24,7 @@ describe('getAuthorizationUri', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); expect(authorizationUri).toEqual( `${authorizationEndpoint}?appid=%3Capp-id%3E&redirect_uri=http%3A%2F%2Flocalhost%3A3001%2Fcallback&response_type=code&scope=snsapi_login&state=some_state` @@ -37,7 +35,7 @@ describe('getAuthorizationUri', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const accessTokenEndpointUrl = new URL(accessTokenEndpoint); @@ -66,7 +64,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(parameters) .reply(200, { errcode: 40_029, errmsg: 'invalid code' }); - await expect(getAccessToken('code', mockedConfig)).rejects.toMatchError( + await expect(getAccessToken('code', mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'invalid code') ); }); @@ -76,7 +74,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(true) .reply(200, { errcode: 40_163, errmsg: 'code been used' }); - await expect(getAccessToken('code', mockedConfig)).rejects.toMatchError( + await expect(getAccessToken('code', mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'code been used') ); }); @@ -86,7 +84,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(true) .reply(200, { errcode: -1, errmsg: 'system error' }); - await expect(getAccessToken('wrong_code', mockedConfig)).rejects.toMatchError( + await expect(getAccessToken('wrong_code', mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'system error', errcode: -1, @@ -123,7 +121,7 @@ describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const userInfoEndpointUrl = new URL(userInfoEndpoint); @@ -144,7 +142,7 @@ describe('getUserInfo', () => { { code: 'code', }, - jest.fn() + vi.fn() ); expect(socialUserInfo).toMatchObject({ id: 'this_is_an_arbitrary_wechat_union_id', @@ -156,7 +154,7 @@ describe('getUserInfo', () => { it('throws General error if code not provided in input', async () => { const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({}, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({}, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, '{}') ); }); @@ -171,7 +169,7 @@ describe('getUserInfo', () => { errmsg: 'missing openid', }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'missing openid', errcode: 41_009, @@ -185,7 +183,7 @@ describe('getUserInfo', () => { .query(parameters) .reply(200, { errcode: 40_001, errmsg: 'invalid credential' }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid, 'invalid credential') ); }); @@ -193,7 +191,7 @@ describe('getUserInfo', () => { it('throws unrecognized error', async () => { nock(userInfoEndpointUrl.origin).get(userInfoEndpointUrl.pathname).query(parameters).reply(500); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toThrow(); + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toThrow(); }); it('throws Error if request failed and errcode is not 40001', async () => { @@ -202,7 +200,7 @@ describe('getUserInfo', () => { .query(parameters) .reply(200, { errcode: 40_003, errmsg: 'invalid openid' }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'invalid openid', errcode: 40_003, @@ -213,7 +211,7 @@ describe('getUserInfo', () => { it('throws SocialAccessTokenInvalid error if response code is 401', async () => { nock(userInfoEndpointUrl.origin).get(userInfoEndpointUrl.pathname).query(parameters).reply(401); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid) ); }); diff --git a/packages/connectors/connector-wecom/package.json b/packages/connectors/connector-wecom/package.json index 622de5d67..4bdf36811 100644 --- a/packages/connectors/connector-wecom/package.json +++ b/packages/connectors/connector-wecom/package.json @@ -24,9 +24,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "engines": { diff --git a/packages/connectors/connector-wecom/src/index.test.ts b/packages/connectors/connector-wecom/src/index.test.ts index ac05c9610..7f4d3a1a2 100644 --- a/packages/connectors/connector-wecom/src/index.test.ts +++ b/packages/connectors/connector-wecom/src/index.test.ts @@ -11,13 +11,11 @@ import { import createConnector, { getAccessToken } from './index.js'; import { mockedConfig } from './mock.js'; -const { jest } = import.meta; - -const getConfig = jest.fn().mockResolvedValue(mockedConfig); +const getConfig = vi.fn().mockResolvedValue(mockedConfig); describe('getAuthorizationUri', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should get a valid uri by redirectUri and state', async () => { @@ -31,7 +29,7 @@ describe('getAuthorizationUri', () => { jti: 'some_jti', headers: {}, }, - jest.fn() + vi.fn() ); const userAgent = 'some_UA'; const isWecom = userAgent.toLowerCase().includes('wxwork'); @@ -48,7 +46,7 @@ describe('getAuthorizationUri', () => { describe('getAccessToken', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const accessTokenEndpointUrl = new URL(accessTokenEndpoint); @@ -74,7 +72,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(parameters) .reply(200, { errcode: 40_029, errmsg: 'invalid code' }); - await expect(getAccessToken(mockedConfig)).rejects.toMatchError( + await expect(getAccessToken(mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'invalid code') ); }); @@ -84,7 +82,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(true) .reply(200, { errcode: 40_163, errmsg: 'code been used' }); - await expect(getAccessToken(mockedConfig)).rejects.toMatchError( + await expect(getAccessToken(mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid, 'code been used') ); }); @@ -94,7 +92,7 @@ describe('getAccessToken', () => { .get(accessTokenEndpointUrl.pathname) .query(true) .reply(200, { errcode: -1, errmsg: 'system error' }); - await expect(getAccessToken(mockedConfig)).rejects.toMatchError( + await expect(getAccessToken(mockedConfig)).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'system error', errcode: -1, @@ -128,7 +126,7 @@ describe('getUserInfo', () => { afterEach(() => { nock.cleanAll(); - jest.clearAllMocks(); + vi.clearAllMocks(); }); const userInfoEndpointUrl = new URL(userInfoEndpoint); @@ -148,7 +146,7 @@ describe('getUserInfo', () => { { code: 'code', }, - jest.fn() + vi.fn() ); expect(socialUserInfo).toMatchObject({ id: 'wecom_id', @@ -160,7 +158,7 @@ describe('getUserInfo', () => { it('throws General error if code not provided in input', async () => { const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({}, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({}, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, '{}') ); }); @@ -175,7 +173,7 @@ describe('getUserInfo', () => { errmsg: 'missing openid', }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'missing openid', errcode: 41_009, @@ -189,7 +187,7 @@ describe('getUserInfo', () => { .query(parameters) .reply(200, { errcode: 40_001, errmsg: 'invalid credential' }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid, 'invalid credential') ); }); @@ -197,7 +195,7 @@ describe('getUserInfo', () => { it('throws unrecognized error', async () => { nock(userInfoEndpointUrl.origin).get(userInfoEndpointUrl.pathname).query(parameters).reply(500); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toThrow(); + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toThrow(); }); it('throws Error if request failed and errcode is not 40001', async () => { @@ -206,7 +204,7 @@ describe('getUserInfo', () => { .query(parameters) .reply(200, { errcode: 40_003, errmsg: 'invalid openid' }); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.General, { errorDescription: 'invalid openid', errcode: 40_003, @@ -217,7 +215,7 @@ describe('getUserInfo', () => { it('throws SocialAccessTokenInvalid error if response code is 401', async () => { nock(userInfoEndpointUrl.origin).get(userInfoEndpointUrl.pathname).query(parameters).reply(401); const connector = await createConnector({ getConfig }); - await expect(connector.getUserInfo({ code: 'code' }, jest.fn())).rejects.toMatchError( + await expect(connector.getUserInfo({ code: 'code' }, vi.fn())).rejects.toStrictEqual( new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid) ); }); diff --git a/packages/connectors/templates/package.json b/packages/connectors/templates/package.json index c0a77d0ce..e4f90ce33 100644 --- a/packages/connectors/templates/package.json +++ b/packages/connectors/templates/package.json @@ -17,9 +17,8 @@ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental", "lint": "eslint --ext .ts src", "lint:report": "pnpm lint --format json --output-file report.json", - "test:only": "NODE_OPTIONS=--experimental-vm-modules jest", - "test": "pnpm build:test && pnpm test:only", - "test:ci": "pnpm test:only --silent --coverage", + "test": "vitest src", + "test:ci": "pnpm run test --silent --coverage", "prepublishOnly": "pnpm build" }, "dependencies": { @@ -29,26 +28,24 @@ "zod": "^3.22.4" }, "devDependencies": { - "@jest/types": "^29.5.0", "@rollup/plugin-commonjs": "^25.0.0", "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-typescript": "^11.0.0", "@silverhand/eslint-config": "5.0.0", "@silverhand/ts-config": "5.0.0", - "@types/jest": "^29.4.0", "@types/node": "^20.9.5", "@types/supertest": "^6.0.0", + "@vitest/coverage-v8": "^1.4.0", "eslint": "^8.44.0", - "jest": "^29.7.0", - "jest-matcher-specific-error": "^1.0.0", "lint-staged": "^15.0.0", "nock": "^13.2.2", "prettier": "^3.0.0", "rollup": "^4.0.0", "rollup-plugin-output-size": "^1.3.0", "supertest": "^6.2.2", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vitest": "^1.4.0" }, "engines": { "node": "^20.9.0" diff --git a/packages/connectors/templates/preset/jest.config.js b/packages/connectors/templates/preset/jest.config.js deleted file mode 100644 index 6ca9a1711..000000000 --- a/packages/connectors/templates/preset/jest.config.js +++ /dev/null @@ -1,7 +0,0 @@ -/** @type {import('jest').Config} */ -const config = { - setupFilesAfterEnv: ['jest-matcher-specific-error'], - roots: ['lib'], -}; - -export default config; diff --git a/packages/connectors/templates/preset/tsconfig.json b/packages/connectors/templates/preset/tsconfig.json index 40492907f..4fa2dd684 100644 --- a/packages/connectors/templates/preset/tsconfig.json +++ b/packages/connectors/templates/preset/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.base", "compilerOptions": { - "types": ["node", "jest", "jest-matcher-specific-error"] + "types": ["node", "vitest/globals"] }, "include": ["src", "types"] } diff --git a/packages/connectors/templates/preset/types/import-meta.d.ts b/packages/connectors/templates/preset/types/import-meta.d.ts deleted file mode 100644 index e016debb5..000000000 --- a/packages/connectors/templates/preset/types/import-meta.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -interface ImportMeta { - jest: typeof jest & { - // Almost same as `jest.mock()`, but factory is required - unstable_mockModule: ( - moduleName: string, - factory: () => T, - options?: jest.MockOptions - ) => typeof jest; - }; -} diff --git a/packages/connectors/templates/preset/vitest.config.ts b/packages/connectors/templates/preset/vitest.config.ts new file mode 100644 index 000000000..32ae898f0 --- /dev/null +++ b/packages/connectors/templates/preset/vitest.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + globals: true, + }, +}) diff --git a/packages/connectors/templates/sync-preset.js b/packages/connectors/templates/sync-preset.js index 099c2a83d..65225ca18 100644 --- a/packages/connectors/templates/sync-preset.js +++ b/packages/connectors/templates/sync-preset.js @@ -17,10 +17,8 @@ const templateKeys = Object.keys(templateJson); /** * An object that contains exceptions for scripts that are allowed to be different from the template. - * - * This is useful when we transiting from Jest to Vitest, as they have different scripts. */ -const scriptExceptions = { 'connector-azuread': ['test', 'test:ci'] }; +const scriptExceptions = {}; const sync = async () => { const packagesDirectory = './'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b39a7d517..371ff877b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -255,9 +255,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -279,24 +276,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -318,6 +309,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-alipay-web: dependencies: @@ -343,9 +337,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -367,24 +358,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -406,6 +391,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-aliyun-dm: dependencies: @@ -425,9 +413,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -446,24 +431,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -485,6 +464,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-aliyun-sms: dependencies: @@ -504,9 +486,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -525,24 +504,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -564,6 +537,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-apple: dependencies: @@ -589,9 +565,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -610,24 +583,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -649,6 +616,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-aws-ses: dependencies: @@ -674,9 +644,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -695,24 +662,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -734,6 +695,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-azuread: dependencies: @@ -756,9 +720,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -777,9 +738,6 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 @@ -792,12 +750,6 @@ importers: eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -841,9 +793,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -862,24 +811,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -901,6 +844,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-facebook: dependencies: @@ -920,9 +866,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -941,24 +884,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -980,6 +917,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-feishu-web: dependencies: @@ -999,9 +939,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1020,24 +957,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1059,6 +990,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-github: dependencies: @@ -1081,9 +1015,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1102,24 +1033,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1141,6 +1066,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-google: dependencies: @@ -1160,9 +1088,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1181,24 +1106,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1220,6 +1139,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-kakao: dependencies: @@ -1239,9 +1161,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1260,24 +1179,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1299,6 +1212,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-logto-email: dependencies: @@ -1318,9 +1234,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@logto/cloud': specifier: 0.2.5-2a72cc4 version: 0.2.5-2a72cc4(zod@3.22.4) @@ -1342,24 +1255,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1381,6 +1288,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-logto-sms: dependencies: @@ -1400,9 +1310,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1421,24 +1328,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1460,6 +1361,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-logto-social-demo: dependencies: @@ -1479,9 +1383,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1500,24 +1401,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1539,6 +1434,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-mailgun: dependencies: @@ -1558,9 +1456,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1579,24 +1474,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1618,6 +1507,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-mock-email: dependencies: @@ -1637,9 +1529,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1658,24 +1547,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1697,6 +1580,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-mock-email-alternative: dependencies: @@ -1716,9 +1602,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1737,24 +1620,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1776,6 +1653,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-mock-sms: dependencies: @@ -1795,9 +1675,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1816,24 +1693,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1855,6 +1726,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-mock-social: dependencies: @@ -1874,9 +1748,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1895,24 +1766,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -1934,6 +1799,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-naver: dependencies: @@ -1953,9 +1821,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -1974,24 +1839,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2013,6 +1872,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-oauth2: dependencies: @@ -2035,9 +1897,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2056,24 +1915,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2095,6 +1948,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-oidc: dependencies: @@ -2123,9 +1979,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2144,24 +1997,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2183,6 +2030,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-saml: dependencies: @@ -2208,9 +2058,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2229,24 +2076,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2268,6 +2109,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-sendgrid-email: dependencies: @@ -2287,9 +2131,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2308,24 +2149,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2347,6 +2182,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-smsaero: dependencies: @@ -2366,9 +2204,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2387,24 +2222,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2426,6 +2255,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-smtp: dependencies: @@ -2448,9 +2280,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2469,9 +2298,6 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 @@ -2481,15 +2307,12 @@ importers: '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2511,6 +2334,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-tencent-sms: dependencies: @@ -2530,9 +2356,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2551,24 +2374,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2590,6 +2407,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-twilio-sms: dependencies: @@ -2609,9 +2429,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2630,24 +2447,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2669,6 +2480,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-wechat-native: dependencies: @@ -2688,9 +2502,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2709,24 +2520,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2748,6 +2553,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-wechat-web: dependencies: @@ -2767,9 +2575,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2788,24 +2593,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.11.20 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.11.20) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2827,6 +2626,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.11.20) packages/connectors/connector-wecom: dependencies: @@ -2846,9 +2648,6 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@jest/types': - specifier: ^29.5.0 - version: 29.6.3 '@rollup/plugin-commonjs': specifier: ^25.0.0 version: 25.0.7(rollup@4.12.0) @@ -2867,24 +2666,18 @@ importers: '@silverhand/ts-config': specifier: 5.0.0 version: 5.0.0(typescript@5.3.3) - '@types/jest': - specifier: ^29.4.0 - version: 29.4.0 '@types/node': specifier: ^20.9.5 version: 20.10.4 '@types/supertest': specifier: ^6.0.0 version: 6.0.1 + '@vitest/coverage-v8': + specifier: ^1.4.0 + version: 1.4.0(vitest@1.4.0) eslint: specifier: ^8.44.0 version: 8.44.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@20.10.4) - jest-matcher-specific-error: - specifier: ^1.0.0 - version: 1.0.0 lint-staged: specifier: ^15.0.0 version: 15.0.2 @@ -2906,6 +2699,9 @@ importers: typescript: specifier: ^5.3.3 version: 5.3.3 + vitest: + specifier: ^1.4.0 + version: 1.4.0(@types/node@20.10.4) packages/console: devDependencies: @@ -6217,14 +6013,14 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.18.10 - '@babel/types': 7.20.2 + '@babel/types': 7.24.0 dev: true /@babel/helper-hoist-variables@7.18.6: resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.20.2 + '@babel/types': 7.24.0 dev: true /@babel/helper-module-imports@7.18.6: @@ -6540,8 +6336,8 @@ packages: '@babel/helper-function-name': 7.19.0 '@babel/helper-hoist-variables': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 - '@babel/parser': 7.20.3 - '@babel/types': 7.20.2 + '@babel/parser': 7.24.0 + '@babel/types': 7.24.0 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: @@ -10962,7 +10758,7 @@ packages: resolution: {integrity: sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==} dependencies: acorn: 8.10.0 - acorn-walk: 8.2.0 + acorn-walk: 8.3.2 dev: true /acorn-jsx@5.3.2(acorn@8.10.0): @@ -21615,7 +21411,7 @@ packages: resolution: {integrity: sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==} engines: {node: '>=10.12.0'} dependencies: - '@jridgewell/trace-mapping': 0.3.18 + '@jridgewell/trace-mapping': 0.3.25 '@types/istanbul-lib-coverage': 2.0.4 convert-source-map: 2.0.0 dev: true @@ -21666,6 +21462,27 @@ packages: vfile-message: 4.0.2 dev: true + /vite-node@1.4.0(@types/node@20.10.4): + resolution: {integrity: sha512-VZDAseqjrHgNd4Kh8icYHWzTKSCZMhia7GyHfhtzLW33fZlG9SwsB6CEhgyVOWkJfJ2pFLrp/Gj1FSfAiqH9Lw==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + dependencies: + cac: 6.7.14 + debug: 4.3.4 + pathe: 1.1.2 + picocolors: 1.0.0 + vite: 5.1.6(@types/node@20.10.4) + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + /vite-node@1.4.0(@types/node@20.11.20): resolution: {integrity: sha512-VZDAseqjrHgNd4Kh8icYHWzTKSCZMhia7GyHfhtzLW33fZlG9SwsB6CEhgyVOWkJfJ2pFLrp/Gj1FSfAiqH9Lw==} engines: {node: ^18.0.0 || >=20.0.0} @@ -21687,6 +21504,42 @@ packages: - terser dev: true + /vite@5.1.6(@types/node@20.10.4): + resolution: {integrity: sha512-yYIAZs9nVfRJ/AiOLCA91zzhjsHUgMjB+EigzFb6W2XTLO8JixBCKCjvhKZaye+NKYHCrkv3Oh50dH9EdLU2RA==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + '@types/node': 20.10.4 + esbuild: 0.19.12 + postcss: 8.4.35 + rollup: 4.12.0 + optionalDependencies: + fsevents: 2.3.3 + dev: true + /vite@5.1.6(@types/node@20.11.20): resolution: {integrity: sha512-yYIAZs9nVfRJ/AiOLCA91zzhjsHUgMjB+EigzFb6W2XTLO8JixBCKCjvhKZaye+NKYHCrkv3Oh50dH9EdLU2RA==} engines: {node: ^18.0.0 || >=20.0.0} @@ -21723,6 +21576,62 @@ packages: fsevents: 2.3.3 dev: true + /vitest@1.4.0(@types/node@20.10.4): + resolution: {integrity: sha512-gujzn0g7fmwf83/WzrDTnncZt2UiXP41mHuFYFrdwaLRVQ6JYQEiME2IfEjU3vcFL3VKa75XhI3lFgn+hfVsQw==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/node': ^18.0.0 || >=20.0.0 + '@vitest/browser': 1.4.0 + '@vitest/ui': 1.4.0 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@types/node': 20.10.4 + '@vitest/expect': 1.4.0 + '@vitest/runner': 1.4.0 + '@vitest/snapshot': 1.4.0 + '@vitest/spy': 1.4.0 + '@vitest/utils': 1.4.0 + acorn-walk: 8.3.2 + chai: 4.4.1 + debug: 4.3.4 + execa: 8.0.1 + local-pkg: 0.5.0 + magic-string: 0.30.7 + pathe: 1.1.2 + picocolors: 1.0.0 + std-env: 3.7.0 + strip-literal: 2.0.0 + tinybench: 2.6.0 + tinypool: 0.8.2 + vite: 5.1.6(@types/node@20.10.4) + vite-node: 1.4.0(@types/node@20.10.4) + why-is-node-running: 2.2.2 + transitivePeerDependencies: + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + /vitest@1.4.0(@types/node@20.11.20): resolution: {integrity: sha512-gujzn0g7fmwf83/WzrDTnncZt2UiXP41mHuFYFrdwaLRVQ6JYQEiME2IfEjU3vcFL3VKa75XhI3lFgn+hfVsQw==} engines: {node: ^18.0.0 || >=20.0.0}