From 1461fcc5f6867f0c17c79822874fcbeab7ff433b Mon Sep 17 00:00:00 2001 From: rishigupta1599 <114384996+rishigupta1599@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:17:53 +0530 Subject: [PATCH] Fixing module exports (#373) * Fixing module exports * percySnapshot as named export as well * Removing function name --- index.js | 14 +++++++++----- tests/index.spec.mjs | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 231421d..0477fd7 100644 --- a/index.js +++ b/index.js @@ -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; @@ -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; @@ -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; diff --git a/tests/index.spec.mjs b/tests/index.spec.mjs index 48d02de..d775568 100644 --- a/tests/index.spec.mjs +++ b/tests/index.spec.mjs @@ -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 }) => {