Skip to content

Commit

Permalink
Merge branch 'master' into release-v1.0.6-beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rishigupta1599 authored Jun 17, 2024
2 parents f41b817 + 1461fcc commit 3be6e74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ENV_INFO = `${playwrightPkg.name}/${playwrightPkg.version}`;
const log = utils.logger('playwright');

// Take a DOM snapshot and post it to the snapshot endpoint
async function percySnapshot(page, name, options) {
const percySnapshot = async function(page, name, options) {
if (!page) throw new Error('A Playwright `page` object is required.');
if (!name) throw new Error('The `name` argument is required.');
if (!(await utils.isPercyEnabled())) return;
Expand Down Expand Up @@ -39,10 +39,10 @@ async function percySnapshot(page, name, options) {
log.error(`Could not take DOM snapshot "${name}"`);
log.error(err);
}
}
};

// Takes Playwright screenshot with Automate
async function percyScreenshot(page, name, options) {
const percyScreenshot = async function(page, name, options) {
if (!page) throw new Error('A Playwright `page` object is required.');
if (!name) throw new Error('The `name` argument is required.');
if (!(await utils.isPercyEnabled())) return;
Expand Down Expand Up @@ -71,6 +71,10 @@ async function percyScreenshot(page, name, options) {
log.error(`Could not take percy screenshot "${name}"`);
log.error(err);
}
}
};

module.exports = { percySnapshot, percyScreenshot, CLIENT_INFO, ENV_INFO };
module.exports = percySnapshot;
module.exports.percySnapshot = percySnapshot;
module.exports.percyScreenshot = percyScreenshot;
module.exports.CLIENT_INFO = CLIENT_INFO;
module.exports.ENV_INFO = ENV_INFO;
3 changes: 2 additions & 1 deletion tests/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import helpers from '@percy/sdk-utils/test/helpers';
import { test, expect } from '@playwright/test';
import { percySnapshot, percyScreenshot, ENV_INFO, CLIENT_INFO } from '../index.js';
import percySnapshot from '../index.js';
import sinon from 'sinon';
import { Utils } from '../utils.js';
const { percyScreenshot, ENV_INFO, CLIENT_INFO } = percySnapshot;

test.describe('percySnapshot', () => {
test.beforeEach(async ({ page }) => {
Expand Down

0 comments on commit 3be6e74

Please sign in to comment.