-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Allow multiple snapshots within a single test (Fixes #93) #96
base: master
Are you sure you want to change the base?
Allow multiple snapshots within a single test (Fixes #93) #96
Conversation
@@ -20,14 +22,29 @@ jest.mock('fs-extra', () => ({ | |||
readFileSync: () => 'cheese', | |||
pathExistsSync: () => false, | |||
copySync: () => null, | |||
removeSync: () => null, | |||
removeSync: jest.fn().mockReturnValue(null), |
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.
Could be made more terse:
removeSync: jest.fn().mockReturnValue(null), | |
removeSync: jest.fn(() => null), |
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 think I will leave this as-is because it is more consistent with other usages in this codebase (mockReturnValue
, mockResolvedValue
, etc).
|
||
const screenshotsFolder = Cypress.config('screenshotsFolder'); | ||
const updateSnapshots = Cypress.env('updateSnapshots') || false; | ||
const failOnSnapshotDiff = | ||
typeof Cypress.env('failOnSnapshotDiff') === 'undefined'; | ||
typeof Cypress.env('failOnSnapshotDiff') === 'undefined' || | ||
Cypress.env('failOnSnapshotDiff'); |
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.
Does this return a Boolean or a string that says true
?
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.
Very good point.
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.
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.
It seems to work as expected.
@crosscompile Any thoughts? Also - do you know what I need to do to stop Chronicler from failing this build. /cc @badeball You reported the original issue so linking you, too. |
b1f8ee9
to
12f0275
Compare
// After completing each test, we need to instruct the plugin to clean up | ||
// the screenshots that were created. | ||
afterEach(() => { | ||
cy.task(CLEAN_SCREENSHOTS, null, { log: false }); |
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.
@NMinhNguyen This will ensure that implementation details of our approach aren't exposed to the user.
@crosscompile Are you happy for this to be merged? |
@crosscompile @jaredpalmer Are either of you going to be able to merge and publish this? I've been waiting since August and at this point I'm starting to consider just publishing my own fork. |
It seems that this project may have been abandoned. :-( @sebinsua If you publish a fork, let me know. |
@jasonharrison Yeah, I'm not sure if/when they'll come back to this, so I've created this fork. I'm just as likely as anybody else within the community to run out of time to maintain this, so what I'll try to do is to follow the Community Continuity Guidelines and give merge access to anybody that gets a contribution in. Hopefully that way we can spread the workload. |
I'm sorry for not coming back to you sooner with feedback on this. I've tested the branch and can confirm that it does indeed solve the problem that we initially had. Thanks for your great work! And I hope this can get merged at some point. |
Allow multiple snapshots within a single test (Fixes #93).
I also fixed a few extra problems I saw:
eslint
now allowsjest
globals.process.cwd
should be reset even if a test fails.cypress run --env failOnSnapshotDiff=true
should resolve totrue
(previously the code only consideredundefined
to betrue
).