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

Allow multiple snapshots within a single test (Fixes #93) #96

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sebinsua
Copy link

@sebinsua sebinsua commented Aug 21, 2019

Allow multiple snapshots within a single test (Fixes #93).

I also fixed a few extra problems I saw:

  • eslint now allows jest globals.
  • Async tests don't have unhandled promises. (Fixing this problem meant the snapshot was created.)
  • process.cwd should be reset even if a test fails.
  • cypress run --env failOnSnapshotDiff=true should resolve to true (previously the code only considered undefined to be true).

@@ -20,14 +22,29 @@ jest.mock('fs-extra', () => ({
readFileSync: () => 'cheese',
pathExistsSync: () => false,
copySync: () => null,
removeSync: () => null,
removeSync: jest.fn().mockReturnValue(null),

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:

Suggested change
removeSync: jest.fn().mockReturnValue(null),
removeSync: jest.fn(() => null),

Copy link
Author

@sebinsua sebinsua Aug 21, 2019

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');

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?

Copy link
Author

Choose a reason for hiding this comment

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

Very good point.

Copy link
Author

Choose a reason for hiding this comment

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

I think this is getting applied to --env args by this.

Copy link
Author

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.

@sebinsua
Copy link
Author

sebinsua commented Aug 21, 2019

@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.

@sebinsua sebinsua force-pushed the fix/93-unable-to-record-multiple-snapshots-within-a-single-test branch from b1f8ee9 to 12f0275 Compare August 29, 2019 18:10
// 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 });
Copy link
Author

@sebinsua sebinsua Aug 29, 2019

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.

@sebinsua
Copy link
Author

@crosscompile Are you happy for this to be merged?

@sebinsua
Copy link
Author

@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.

@jasonharrison
Copy link

It seems that this project may have been abandoned. :-( @sebinsua If you publish a fork, let me know.

@sebinsua
Copy link
Author

@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.

@badeball
Copy link

badeball commented Feb 10, 2020

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.

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.

Unable to record multiple snapshots in a single test
4 participants