Feature/replace ava nyc enzyme and sinon for jest#8
Conversation
There was a problem hiding this comment.
This kind of changes requires to be aware if the the improvement of testing legibility and config simplification is significant
So it would be great if the testing files were not changed the .spec.js to .test.js it would be easier to see the different between changes, now all deleted files are not referenced to the new ones, so the tracking is harder to follow. I recommend analize each review in order to clean all unnecessary configuration and aim a better version of this propourse .
Also I would like to remark, all kind of PR must be related to an issue with the motivation and a detailed plan to onboard the issue. This would help to discuss, prepare and estimate the required steps to reach the goal.
| jest.spyOn(console, 'warn'); | ||
| render(<Consumer />); | ||
| expect(console.warn).toBeCalledTimes(1); | ||
| console.warn.mockRestore(); |
There was a problem hiding this comment.
this would be more precise if the test checks the content of the message
There was a problem hiding this comment.
Rigth, I will make the change
| const { getByText, rerender } = render(<I18nProvider i18n={i18n}><Consumer word="Teléfono" /></I18nProvider>); | ||
| expect(getByText('Phone')).toBeInTheDocument(); | ||
| await i18n.setLocale('de'); | ||
| rerender(<I18nProvider i18n={i18n}><Consumer word="Teléfono" /></I18nProvider>); |
There was a problem hiding this comment.
Yeah, that error is resolved in a future PR
| @@ -0,0 +1,5 @@ | |||
| // jest-dom adds custom jest matchers for asserting on DOM nodes. | |||
There was a problem hiding this comment.
This file seems that came from a boilerplate configuration but I don't know if is required for this feature
There was a problem hiding this comment.
The extension is wrong but the file is neccessary to add the testing/library-react assertings to jest
| const i18n = i18njs(I18N_DATA); | ||
| i18n.on('loaded', () => resolve(i18n)); | ||
| }); | ||
| } |
There was a problem hiding this comment.
I don't change the eslint config, but I had thought of change it in the future
| @@ -0,0 +1,41 @@ | |||
|
|
|||
There was a problem hiding this comment.
This feature seems to try to resolve a conditional environment setting,
To preserve the project settings as much as possible and keep it centralized, I suggest follow the previous method using a Babel feature to solve this problem.
https://babeljs.io/docs/en/6.26.3/babelrc#env-option
Also recommend not include this commit to keep the tree changes clean and simple (rebase from the begining of this PR)
There was a problem hiding this comment.
I don't find any way to do this with package.json, can you show me a example?
There was a problem hiding this comment.
All the configuration available in .babelrc are compatible inside the package.sjon babel declaration.
https://babeljs.io/docs/en/6.26.3/babelrc#use-via-packagejson
{
"babel": {
"env": {
// Specific configuration for each enviroment
"test": {
....
}
}
}
}| }); | ||
|
|
||
| it('translates correctly', async () => { | ||
| const i18n = await fetchI18n(); |
There was a problem hiding this comment.
Same as above, where is the assertion to check the translation is the expected?
src/withI18n.test.js
Outdated
| render(<I18nProvider i18n={i18n}><WrappedComponent /></I18nProvider>); | ||
| }); | ||
|
|
||
| // it('translates correctly', async () => { |
There was a problem hiding this comment.
Commented specs? use .skip if the test is planned to be tested in a future or remove if not need it
There was a problem hiding this comment.
Rigth, the test fail actually, I thought of removing the comments when the code is fixed
| ], | ||
| "testEnvironment": "jest-environment-jsdom-fourteen", | ||
| "transform": { | ||
| "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest" |
There was a problem hiding this comment.
In this case the project is not and react app so there's no other kind of files rather than js
There was a problem hiding this comment.
The idea was to have the same config in all the projects, not just the bare minimun
| "roots": [ | ||
| "<rootDir>/src" | ||
| ], | ||
| "collectCoverageFrom": [ |
There was a problem hiding this comment.
This is redudant theres no other format inside src directory
| "collectCoverageFrom": [ | ||
| "src/**/*.{js,jsx}" | ||
| ], | ||
| "setupFilesAfterEnv": [ |
There was a problem hiding this comment.
This file has a previous review to see if is really need it


No description provided.