From 29ef8b5ab3d68e0f14e2e1abdfc87812c52d36ae Mon Sep 17 00:00:00 2001 From: Embbnux Ji Date: Mon, 23 Oct 2023 15:06:22 +0800 Subject: [PATCH] chore: fix test without build --- lerna.json | 3 ++- subscriptions-deprecated/jest.setup.js | 4 ++++ subscriptions-deprecated/package.json | 5 +++-- .../src/subscription/CachedSubscription-spec.ts | 2 +- .../src/subscription/Subscription-spec.ts | 2 +- subscriptions-deprecated/src/test/test.ts | 4 +++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lerna.json b/lerna.json index 1be1b18f..851bdf0b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,3 +1,4 @@ { - "version": "0.0.0" + "version": "0.0.0", + "useWorkspaces": true } diff --git a/subscriptions-deprecated/jest.setup.js b/subscriptions-deprecated/jest.setup.js index db452fb8..796d1341 100644 --- a/subscriptions-deprecated/jest.setup.js +++ b/subscriptions-deprecated/jest.setup.js @@ -1 +1,5 @@ // setup file + +if (process.env.JEST_ENV === 'node') { + require('@ringcentral/sdk/src/index.ts'); +} diff --git a/subscriptions-deprecated/package.json b/subscriptions-deprecated/package.json index 5490acc2..ef86b195 100644 --- a/subscriptions-deprecated/package.json +++ b/subscriptions-deprecated/package.json @@ -4,8 +4,9 @@ "scripts": { "clean": "rimraf dist/* lib/* es6/* coverage/* .nyc_output .rpt2_cache", "test": "npm run jest", - "test:coverage": "jest --coverage", - "jest": "jest", + "test:coverage": "JEST_ENV=node jest --coverage", + "jest": "JEST_ENV=node jest", + "jest:browser": "JEST_ENV=jsdom jest", "build": "npm run clean && npm run build:tsc:es5 && npm run build:tsc:es6 && npm run build:webpack", "build:tsc:es5": "tsc", "build:tsc:es6": "tsc --project tsconfig.es6.json", diff --git a/subscriptions-deprecated/src/subscription/CachedSubscription-spec.ts b/subscriptions-deprecated/src/subscription/CachedSubscription-spec.ts index 2c8db42c..fc364da9 100644 --- a/subscriptions-deprecated/src/subscription/CachedSubscription-spec.ts +++ b/subscriptions-deprecated/src/subscription/CachedSubscription-spec.ts @@ -1,4 +1,4 @@ -import {asyncTest, expect} from '@ringcentral/sdk/lib/test/test'; +import {asyncTest, expect} from '@ringcentral/sdk/src/test/test'; import {createSubscriptions} from '../test/test'; diff --git a/subscriptions-deprecated/src/subscription/Subscription-spec.ts b/subscriptions-deprecated/src/subscription/Subscription-spec.ts index 0999332d..e493aa43 100644 --- a/subscriptions-deprecated/src/subscription/Subscription-spec.ts +++ b/subscriptions-deprecated/src/subscription/Subscription-spec.ts @@ -1,4 +1,4 @@ -import {apiCall, asyncTest, expect, expectThrows} from '@ringcentral/sdk/lib/test/test'; +import {apiCall, asyncTest, expect, expectThrows} from '@ringcentral/sdk/src/test/test'; import {createSubscriptions, subscribeGeneric} from '../test/test'; diff --git a/subscriptions-deprecated/src/test/test.ts b/subscriptions-deprecated/src/test/test.ts index 6242b0ec..ec7eab2a 100644 --- a/subscriptions-deprecated/src/test/test.ts +++ b/subscriptions-deprecated/src/test/test.ts @@ -1,5 +1,7 @@ -import {apiCall} from '@ringcentral/sdk/lib/test/test'; import PubNub from 'pubnub'; + +import {apiCall} from '@ringcentral/sdk/src/test/test'; + import {Subscriptions} from '../Subscriptions'; class PubNubMock extends PubNub {