Skip to content

Feature/replace ava nyc enzyme and sinon for jest#8

Open
Kelvur wants to merge 9 commits intodevelopfrom
feature/Replace_ava_nyc_enzyme_and_sinon_for_jest
Open

Feature/replace ava nyc enzyme and sinon for jest#8
Kelvur wants to merge 9 commits intodevelopfrom
feature/Replace_ava_nyc_enzyme_and_sinon_for_jest

Conversation

@Kelvur
Copy link
Member

@Kelvur Kelvur commented Mar 28, 2020

No description provided.

@Kelvur Kelvur requested a review from rubeniskov March 28, 2020 19:54
Copy link
Member

@rubeniskov rubeniskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be more precise if the test checks the content of the message

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the tests, I receive this error
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that error is resolved in a future PR

@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file seems that came from a boilerplate configuration but I don't know if is required for this feature

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any miss configuration about eslinter?, I notice this semicollon is not revealing through the terminal output when the linter executes

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't change the eslint config, but I had thought of change it in the future

@@ -0,0 +1,41 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find any way to do this with package.json, can you show me a example?

Copy link
Member

@rubeniskov rubeniskov Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, where is the assertion to check the translation is the expected?

render(<I18nProvider i18n={i18n}><WrappedComponent /></I18nProvider>);
});

// it('translates correctly', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented specs? use .skip if the test is planned to be tested in a future or remove if not need it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the project is not and react app so there's no other kind of files rather than js

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to have the same config in all the projects, not just the bare minimun

"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redudant theres no other format inside src directory

"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"setupFilesAfterEnv": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has a previous review to see if is really need it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants