From bfb4a12f6abb36a4c35fd15f1a9661a4cd725483 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Fri, 26 Nov 2021 15:23:56 +0800 Subject: [PATCH] fix mock ChartClient add comments --- superset-frontend/spec/helpers/setupSupersetClient.js | 4 +++- superset-frontend/spec/helpers/shim.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/superset-frontend/spec/helpers/setupSupersetClient.js b/superset-frontend/spec/helpers/setupSupersetClient.js index 6b316319b8a07..c65f684266edf 100644 --- a/superset-frontend/spec/helpers/setupSupersetClient.js +++ b/superset-frontend/spec/helpers/setupSupersetClient.js @@ -17,7 +17,9 @@ * under the License. */ import fetchMock from 'fetch-mock'; -import { SupersetClient } from '@superset-ui/core'; +// https://jestjs.io/docs/jest-object#jestmockmodulename-factory-options +// in order to mock modules in test case, so avoid absolute import module +import { SupersetClient } from '../../packages/superset-ui-core/src/connection'; export default function setupSupersetClient() { // The following is needed to mock out SupersetClient requests diff --git a/superset-frontend/spec/helpers/shim.ts b/superset-frontend/spec/helpers/shim.ts index e2cef968ca769..9371a00291c56 100644 --- a/superset-frontend/spec/helpers/shim.ts +++ b/superset-frontend/spec/helpers/shim.ts @@ -23,10 +23,13 @@ import 'jest-enzyme'; import jQuery from 'jquery'; import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; -import { configure as configureTranslation } from '@superset-ui/core'; +// https://jestjs.io/docs/jest-object#jestmockmodulename-factory-options +// in order to mock modules in test case, so avoid absolute import module +import { configure as configureTranslation } from '../../packages/superset-ui-core/src/translation'; import { Worker } from './Worker'; import { IntersectionObserver } from './IntersectionObserver'; import setupSupersetClient from './setupSupersetClient'; +import CacheStorage from './CacheStorage'; configure({ adapter: new Adapter() }); @@ -49,6 +52,7 @@ g.window.performance = { now: () => new Date().getTime() }; g.window.Worker = Worker; g.window.IntersectionObserver = IntersectionObserver; g.URL.createObjectURL = () => ''; +g.caches = new CacheStorage(); Object.defineProperty(window, 'matchMedia', { writable: true,