Skip to content
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

feat: add beforeEach and afterEach hooks #11

Merged
merged 10 commits into from
Jul 10, 2020
Merged

feat: add beforeEach and afterEach hooks #11

merged 10 commits into from
Jul 10, 2020

Conversation

hyanmandian
Copy link
Contributor

@hyanmandian hyanmandian commented Jul 9, 2020

Closes #9

@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2020

Codecov Report

Merging #11 into master will decrease coverage by 0.04%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #11      +/-   ##
==========================================
- Coverage   82.72%   82.67%   -0.05%     
==========================================
  Files           3        3              
  Lines         272      277       +5     
==========================================
+ Hits          225      229       +4     
- Misses         47       48       +1     
Impacted Files Coverage Δ
src/index.js 75.53% <85.71%> (+0.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a63deb8...f86a4b7. Read the comment docs.

@lukeed
Copy link
Owner

lukeed commented Jul 9, 2020

Hey thanks!

This still has some work to go (types and docs), but we also need to thinking about the implementation. I've had this originally too, but it doesn't account for:

  • beforeEach throwing an Error
  • afterEach throwing an Error
  • test throwing an Error & so afterEach can't cleanup

I will also ping you from #9 about another discussion point

@hyanmandian
Copy link
Contributor Author

I implemented the idea you suggested in #9 , added missing docs, added missing types, and handle hooks exceptions. Can you help me to find a way to test if it works?

@lukeed
Copy link
Owner

lukeed commented Jul 9, 2020

Sorry @hyanmandian 🙈 Can you revert that last commit? It actually causes more issues with timing and control flow than the previous state.

The rest is looking good! I can add the missing bits to what was there.
Thanks!

@hyanmandian
Copy link
Contributor Author

Done @lukeed !

@lukeed
Copy link
Owner

lukeed commented Jul 9, 2020

This is looking good, thanks @hyanmandian! I'll be able to add the remaining bits tonight 🙌

@lukeed lukeed added this to the 0.2.0 milestone Jul 9, 2020
write(PASS);
num++;
} catch (err) {
for (hook of aEach) await hook();
Copy link
Owner

Choose a reason for hiding this comment

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

Sorry for the delay – I was thinking about it, and this is all the "additional cleanup" that was needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice!

Copy link
Owner

@lukeed lukeed left a comment

Choose a reason for hiding this comment

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

Tests pass – coverage dropped a tiny bit (compared to your last commit) because of the line I added.

Thank you! 🙌

@lukeed lukeed merged commit c3965c8 into lukeed:master Jul 10, 2020
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.

Add beforeEach & afterEach hooks
3 participants