-
-
Notifications
You must be signed in to change notification settings - Fork 734
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
Comprehensive cleanup after each test #1465
Conversation
- And misc adjacent cleanup
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 is great! Maybe consider calling the file cleanup_after_all.js
? It might be more clear than cleanup_hook.js
Sure. I think I'll use |
🎉 This PR is included in version 11.0.0-beta.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 11.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This adds a global `afterEach` hook that resets nock global state to the condition it's in when it's initially `require`d. It's worth noting that there isn't a single function for doing this; I've got four function calls here to accomplish that. It's worth taking a moment here to validate that this is indeed the correct sequence of calls. See #1441 for some discussion on that. It removes most or all of the one-off global-state cleanup code that's sprinkled among the tests. - Tests may now assume that, at the time they're invoked, that nock's initial state will match the state it has when it has just been `require`d. - Tests are not responsible for restoring that state afterward. - If tests need nock in a _different_ starting state, it's up to them to set it. - If tests create _other_ state, such as starting a server, it's up to them to clean it up. I've included some miscellaneous adjacent style cleanup. I've deferred the various `test_back*` suites because they are all intertwingled, and require a bit more focused effort to unravel.
This adds a global `afterEach` hook that resets nock global state to the condition it's in when it's initially `require`d. It's worth noting that there isn't a single function for doing this; I've got four function calls here to accomplish that. It's worth taking a moment here to validate that this is indeed the correct sequence of calls. See #1441 for some discussion on that. It removes most or all of the one-off global-state cleanup code that's sprinkled among the tests. - Tests may now assume that, at the time they're invoked, that nock's initial state will match the state it has when it has just been `require`d. - Tests are not responsible for restoring that state afterward. - If tests need nock in a _different_ starting state, it's up to them to set it. - If tests create _other_ state, such as starting a server, it's up to them to clean it up. I've included some miscellaneous adjacent style cleanup. I've deferred the various `test_back*` suites because they are all intertwingled, and require a bit more focused effort to unravel.
This adds a global `afterEach` hook that resets nock global state to the condition it's in when it's initially `require`d. It's worth noting that there isn't a single function for doing this; I've got four function calls here to accomplish that. It's worth taking a moment here to validate that this is indeed the correct sequence of calls. See #1441 for some discussion on that. It removes most or all of the one-off global-state cleanup code that's sprinkled among the tests. - Tests may now assume that, at the time they're invoked, that nock's initial state will match the state it has when it has just been `require`d. - Tests are not responsible for restoring that state afterward. - If tests need nock in a _different_ starting state, it's up to them to set it. - If tests create _other_ state, such as starting a server, it's up to them to clean it up. I've included some miscellaneous adjacent style cleanup. I've deferred the various `test_back*` suites because they are all intertwingled, and require a bit more focused effort to unravel.
This adds a global
afterEach
hook that resets nock global state to the condition it's in when it's initiallyrequire
d. It's worth noting that there isn't a single function for doing this; I've got four function calls here to accomplish that. It's worth taking a moment here to validate that this is indeed the correct sequence of calls. See #1441 for some discussion on that.It removes most or all of the one-off global-state cleanup code that's sprinkled among the tests.
require
d.I've included some miscellaneous adjacent style cleanup.
I've deferred the various
test_back*
suites because they are all intertwingled, and require a bit more focused effort to unravel.