-
Notifications
You must be signed in to change notification settings - Fork 0
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
Recreate golden with this before each test #41
Conversation
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.
Whoa, this is super cool! Makes things so much cleaner.
src/browser/vdiff.js
Outdated
beforeEach() { | ||
const { currentTest } = this; | ||
chai.Assertion.addMethod('golden', function(...args) { | ||
return ScreenshotAndCompare.call({ test: currentTest, elem: this._obj }, ...args); // eslint-disable-line no-invalid-this |
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.
I guess this._obj
is a Chai thing eh, like it's whatever you call expect(thing).to.be.whatever
with?
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.
Amazing!
🎉 This PR is included in version 0.12.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Adds a
beforeEach
root hook to mocha, in which thegolden
assertion method is recreated to callScreenshotAndCompare
with the current test and fixture element inthis
.Avoids needing to pass
this
togolden()
, which also allows arrow functions to be used.