-
Notifications
You must be signed in to change notification settings - Fork 232
test: Update tests to be compatible with Jest 27 #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Bumps [kcd-scripts](https://github.com/kentcdodds/kcd-scripts) from 10.0.0 to 11.1.0. - [Release notes](https://github.com/kentcdodds/kcd-scripts/releases) - [Changelog](https://github.com/kentcdodds/kcd-scripts/blob/main/CHANGELOG.md) - [Commits](kentcdodds/kcd-scripts@v10.0.0...v11.1.0) --- updated-dependencies: - dependency-name: kcd-scripts dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #639 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 15 15
Lines 235 235
Branches 29 29
=========================================
Hits 235 235 Continue to review full report at Codecov.
|
const expectedRenderer = require('../native/pure') as ReactHooksRenderer | ||
const actualRenderer = require('../pure') as ReactHooksRenderer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the only test where I felt the require
s in the tests were still appropriate. I worked around the issue by changing to use the pure
imports instead. This left the non-pure
import uncovered, which is why I introduced the simplified test file for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a fairly straight forward refactor.
RE. Duplication, I guess this is where it would be useful to have a set of tests that are called with each renderer type. Could we do forEach
loops with the specific functions from the library to avoid duplication? Although not exactly "pretty", it could work.
I suppose in terms of structure we'd then hoist tests out of the target and into a specific test
folder.
Yeah, there's also In my ideal world, the test file would execute multiple times with different renderers so that the import of on doesn't affect the others (e.g. the cleanup and error suppression with be set up and torn down multiple times), but I've been looking into that it is seems to either be very difficult right now.
I was thinking we could just put them in |
* chore(deps-dev): bump kcd-scripts from 10.0.0 to 11.1.0 Bumps [kcd-scripts](https://github.com/kentcdodds/kcd-scripts) from 10.0.0 to 11.1.0. - [Release notes](https://github.com/kentcdodds/kcd-scripts/releases) - [Changelog](https://github.com/kentcdodds/kcd-scripts/blob/main/CHANGELOG.md) - [Commits](kentcdodds/kcd-scripts@v10.0.0...v11.1.0) --- updated-dependencies: - dependency-name: kcd-scripts dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * test: Update tests to be compatible with Jest 27 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Yeah i think if we're merging them that's the direction to take |
🎉 This PR is included in version 7.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What:
Update test suite to be compatible with
jest
27.Why:
The PR to update
kcd-scripts
is failing because of some changes injest
27 that preventbeforeEach
andafterEach
hooks being added after the tests have started to run. In our test suite, we were doing this in order to test the auto cleanup and error suppression features.How:
Most of the changes here involve moving the setup and
require
statements outside of thebeforeEach
/beforeAll
hooks they were bing called it (i.e. after the tests were running) into thedescribe
blocks. While researching how to deal with this, I discovered thatjest
runs each test file in it's own sandbox, so much of the protection I thought using the test hooks were giving us is there within the file which was sufficient for most of the affected tests.I also took the opportunity to review how the imports were occurring and found a few and were using
require
when a regularimport
would work for that case. I also found a few unused imports to clean up.Checklist:
I really want to look at removing the duplication in the test suite.