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

fix: disableAutoSnapshot not working as expected #134

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/cypress/src/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ beforeEach(() => {

afterEach(() => {
// don't take snapshots when running `cypress open`
if (Cypress.env('disableAutoSnapshot') || !Cypress.config('isTextTerminal')) {
if (!Cypress.config('isTextTerminal')) {
return;
}
// can we be sure this always fires after all the requests are back?
cy.document().then((doc) => {
const automaticSnapshot = snapshot(doc);
const automaticSnapshots = !Cypress.env('disableAutoSnapshot')
? [{ snapshot: snapshot(doc) }]
: [];
// @ts-expect-error will fix when Cypress has its own package
cy.get('@manualSnapshots').then((manualSnapshots = []) => {
cy.url().then((url) => {
Expand All @@ -34,7 +36,7 @@ afterEach(() => {
payload: {
// @ts-expect-error relativeToCommonRoot is on spec (but undocumented)
testTitlePath: [Cypress.spec.relativeToCommonRoot, ...Cypress.currentTest.titlePath],
domSnapshots: [...manualSnapshots, { snapshot: automaticSnapshot }],
domSnapshots: [...manualSnapshots, ...automaticSnapshots],
chromaticStorybookParams: {
...(Cypress.env('diffThreshold') && { diffThreshold: Cypress.env('diffThreshold') }),
...(Cypress.env('delay') && { delay: Cypress.env('delay') }),
Expand Down