Skip to content

Commit

Permalink
fix: suppress translation warning in jest
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Jun 21, 2022
1 parent c79b0d6 commit ad82ce6
Show file tree
Hide file tree
Showing 5 changed files with 14 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?.NODE_ENV !== '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.NODE_ENV = 'production';
});

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

describe('new Translator(config)', () => {
Expand Down
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 ad82ce6

Please sign in to comment.