Skip to content

Commit 6ceba50

Browse files
authored
Remove i18n debug mode in test suite (#2980)
1 parent da6a986 commit 6ceba50

File tree

4 files changed

+11
-25
lines changed

4 files changed

+11
-25
lines changed

craco.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ const cracoConfig = {
151151
'<rootDir>/node_modules/vfile/lib';
152152
jestConfig.moduleNameMapper['vfile/do-not-use-conditional-minurl'] =
153153
'<rootDir>/node_modules/vfile/lib';
154+
155+
jestConfig.setupFiles = [
156+
...jestConfig.setupFiles,
157+
'./src/i18n/i18n.ts' // Setup i18next configuration
158+
]
154159
return jestConfig;
155160
}
156161
},

src/i18n/i18n.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { initReactI18next } from 'react-i18next';
44

55
import { i18nLanguageCode, resources } from './locales';
66

7+
const isDevelopment = process.env.NODE_ENV === 'development';
8+
79
i18n
810
.use(LanguageDetector)
911
.use(initReactI18next)
1012
.init({
1113
fallbackLng: i18nLanguageCode.ENGLISH,
12-
debug: true,
14+
debug: isDevelopment,
1315
resources,
1416
interpolation: {
1517
escapeValue: false // not needed for react as it escapes by default

src/i18n/i18nForTests.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/pages/login/__tests__/Login.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { render } from '@testing-library/react';
2-
import { I18nextProvider } from 'react-i18next';
32
import { Provider, useDispatch } from 'react-redux';
43
import * as ReactRouter from 'react-router';
54
import { StaticRouter } from 'react-router-dom/server';
65
import { fetchAuth } from 'src/commons/application/actions/SessionActions';
7-
import i18n from 'src/i18n/i18nForTests';
86

97
import { mockInitialStore } from '../../../commons/mocks/StoreMocks';
108
import Login from '../Login';
@@ -37,11 +35,9 @@ describe('Login', () => {
3735
const store = mockInitialStore();
3836
const app = (
3937
<Provider store={store}>
40-
<I18nextProvider i18n={i18n}>
41-
<StaticRouter location="/login">
42-
<Login />
43-
</StaticRouter>
44-
</I18nextProvider>
38+
<StaticRouter location="/login">
39+
<Login />
40+
</StaticRouter>
4541
</Provider>
4642
);
4743
const tree = render(app);

0 commit comments

Comments
 (0)