Skip to content

Commit

Permalink
fix: suppress translation warning in jest (#20404)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9fad26f)
  • Loading branch information
zhaoyongjie authored and michael-s-molina committed Jun 28, 2022
1 parent 4e93690 commit f58ad25
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
14 changes: 8 additions & 6 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions superset-frontend/packages/superset-ui-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@types/d3-time-format": "^2.1.0",
"@types/lodash": "^4.14.149",
"@types/math-expression-evaluator": "^1.2.1",
"@types/node": "^18.0.0",
"@types/rison": "0.0.6",
"@types/seedrandom": "^2.4.28",
"@types/fetch-mock": "^7.3.3",
Expand Down
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 (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,10 +41,12 @@ describe('Translator', () => {
spy.mockImplementation((info: any) => {
throw new Error(info);
});
process.env.WEBPACK_MODE = 'production';
});

afterAll(() => {
spy.mockRestore();
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';
3 changes: 2 additions & 1 deletion superset-frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"types": [
"@emotion/react/types/css-prop",
"jest",
"@testing-library/jest-dom"
"@testing-library/jest-dom",
"@types/node"
],

/* Emit */
Expand Down

0 comments on commit f58ad25

Please sign in to comment.