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

✨ Disable Percy when Cypress is in interactive mode #321

Merged
merged 1 commit into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cypress/integration/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,31 @@ describe('percySnapshot', () => {
'[percy] Error: 500 Internal Server Error'
]);
});

describe('in interactive mode', () => {
let ogInteractive;

beforeEach(() => {
ogInteractive = Cypress.config('isInteractive');
});

afterEach(() => {
Cypress.config('isInteractive', ogInteractive);
});

it('disables snapshots', () => {
Cypress.config('isInteractive', true);
cy.percySnapshot('Snapshot name');

cy.get('@log').should((spy) => {
expect(spy).to.be.calledWith(
match({
name: 'percySnapshot',
displayName: 'percy',
message: 'Disabled in interactive mode'
})
);
});
});
});
});
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Cypress.Commands.add('percySnapshot', (name, options) => {
name = name || cy.state('runnable').fullTitle();

cy.then(async () => {
if (Cypress.config('isInteractive') &&
!Cypress.config('enablePercyInteractiveMode')) {
return cylog('Disabled in interactive mode', {
details: 'use "cypress run" instead of "cypress open"',
name
});
}

// Check if Percy is enabled
if (!await utils.isPercyEnabled()) {
return cylog('Not running', { name });
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@
dependencies:
dotenv "^8.2.0"

"@percy/logger@^1.0.0-beta.44", "@percy/logger@^1.0.0-beta.47":
"@percy/logger@^1.0.0-beta.47":
version "1.0.0-beta.47"
resolved "https://registry.yarnpkg.com/@percy/logger/-/logger-1.0.0-beta.47.tgz#72d91b693b43c59f1cccffdfafec70adc9ffc1a8"
integrity sha512-6mDHvIQ8wJCN7dd9bnnKtT/VrE+HBTB+U9C7a7vSakC35DnY4QrxH1sbK4hAO8wc2aw6YR3vepX2w/ZYpeuqnA==
Expand Down