michael-s-molina opened a new pull request #13079: URL: https://github.com/apache/superset/pull/13079
### SUMMARY This PR improves [current](https://github.com/apache/superset/pull/11771) RTL configuration and contributes to [SIP 56](https://github.com/apache/superset/issues/11688). The changes made here has aim to: ### Avoid matchers conflict Enzyme matchers were conflicting with jest-dom matchers. To avoid this I moved `import '@testing-library/jest-dom/extend-expect';` from `spec/helpers/setup.ts` to `spec/helpers/testing-library.tsx`. This way Enzyme matchers are the default option (99% of the tests) and we can choose to use jest-dom matchers in our RTL tests using custom render functions from `testing-library.tsx` or importing `@testing-library/jest-dom/extend-expect` directly in each test file. ### Improve user events simulation in our tests With the use of [@testing-library/user-event](https://github.com/testing-library/user-event) we have a better level of abstraction to simulate user events. Here are some examples of the new API that can be used in our tests: `click`, `dblClick`, `type`, `upload`, `clear`, `selectOptions`, `deselectOptions`, `tab`, `hover`, `unhover`, `paste`, `specialChars` ### Support additional ESLint rules With the addition of [plugin:jest-dom/recommended](https://github.com/testing-library/eslint-plugin-jest-dom) to ESLint plugins list we can enforce another set of tests best practices and improve the quality of our tests. An important side note is that ESLint wasn't working properly for some files because of this configuration problem: `Error while loading rule 'jest/no-deprecated-functions': Unable to detect Jest version - please ensure jest package is installed, or otherwise set version explicitly` To fix this, I included a configuration option to automatically detect Jest version. Another important point is that ESLint rules of `eslint-plugin-testing-library` are not currently working with the import of custom functions from a different library name. In our case the rules will not be applied when using `import { render, screen } from 'spec/helpers/testing-library';` If we use `import { render, screen } from ‘@testing-library/react’;` then ESLint works. They are aware of this [issue](https://github.com/testing-library/eslint-plugin-testing-library/issues/173) and are already working on a fix in version 4. @ktmud @rusackas @geido @junlincc ### TEST PLAN 1 - Execute all tests 2- They should pass 1 - Execute ESLint 2 - No errors should be found ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Changes UI - [ ] Requires DB Migration. - [ ] Confirm DB Migration upgrade and downgrade tested. - [x] Introduces new feature or API - [ ] Removes existing feature or API ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
