Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Jun 21, 2022
1 parent ad82ce6 commit 4efc210
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class Translator {
*/
addTranslation(key: string, texts: ReadonlyArray<string>) {
const translations = this.i18n.options.locale_data.superset;
if (process?.env?.NODE_ENV !== 'test' && key in translations) {
if (process.env.WEBPACK_MODE !== 'test' && key in translations) {
logging.warn(`Duplicate translation key "${key}", will override.`);
}
translations[key] = texts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ describe('Translator', () => {
spy.mockImplementation((info: any) => {
throw new Error(info);
});
process.env.NODE_ENV = 'production';
process.env.WEBPACK_MODE = 'production';
});

afterAll(() => {
spy.mockRestore();
process.env.NODE_ENV = 'test';
process.env.WEBPACK_MODE = 'test';
});

describe('new Translator(config)', () => {
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/spec/helpers/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ setupSupersetClient();
jest.mock('src/hooks/useTabId', () => ({
useTabId: () => 1,
}));

process.env.WEBPACK_MODE = 'test';

0 comments on commit 4efc210

Please sign in to comment.