How to use percy-client - 10 common examples

To help you get started, we’ve selected a few percy-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github percy / percy-webdriverio / src / main.js View on Github external
constructor(browser) {
    if (!browser) {
      throw new Error('A WebdriverIO instance is needed to initialise percy-webdriverio');
    }
    browser.percy = { assetLoaders: [] };

    const enabled = isEnabled();
    const token = process.env.PERCY_TOKEN;
    const apiUrl = process.env.PERCY_API;
    const clientInfo = `percy-webdriverio ${version}`;
    browser.percy.environment = new Environment(process.env);
    browser.percy.percyClient = new PercyClient({ token, apiUrl, clientInfo });

    // adding `async` as function name disables the synchronous behavior of WebdriverIO commands
    // eslint-disable-next-line prefer-arrow-callback
    browser.addCommand('__percyReinit', function async() {
      browser.percy = { assetLoaders: [] };
      browser.percy.environment = new Environment(process.env);
      browser.percy.percyClient = new PercyClient({ token, apiUrl, clientInfo });
    });

    browser.addCommand('percyFinalizeBuild', () => {
      throw new Error(
        '[percy] browser.percyFinalizeBuild is deprecated, see https://github.com/percy/percy-webdriverio/pull/19',
      );
    });

    browser.addCommand('percyUseAssetLoader', () => {
github percy / percy-webdriverio / src / main.js View on Github external
constructor(browser) {
    if (!browser) {
      throw new Error('A WebdriverIO instance is needed to initialise percy-webdriverio');
    }
    browser.percy = { assetLoaders: [] };

    const enabled = isEnabled();
    const token = process.env.PERCY_TOKEN;
    const apiUrl = process.env.PERCY_API;
    const clientInfo = `percy-webdriverio ${version}`;
    browser.percy.environment = new Environment(process.env);
    browser.percy.percyClient = new PercyClient({ token, apiUrl, clientInfo });

    // adding `async` as function name disables the synchronous behavior of WebdriverIO commands
    // eslint-disable-next-line prefer-arrow-callback
    browser.addCommand('__percyReinit', function async() {
      browser.percy = { assetLoaders: [] };
      browser.percy.environment = new Environment(process.env);
      browser.percy.percyClient = new PercyClient({ token, apiUrl, clientInfo });
    });

    browser.addCommand('percyFinalizeBuild', () => {
      throw new Error(
        '[percy] browser.percyFinalizeBuild is deprecated, see https://github.com/percy/percy-webdriverio/pull/19',
      );
    });
github percy / react-percy / integration-tests / react-percy / __tests__ / basic-tests.js View on Github external
it('creates snapshots for each test case', () => {
  expect(percy.createSnapshot.mock.calls).toMatchSnapshot();
});
github percy / react-percy / integration-tests / react-percy / __tests__ / webpack-config-tests.js View on Github external
it('handles ES6 webpack configs', async () => {
  await run(['--config', 'webpack/webpack.config.babel.js']);

  expect(percy.createSnapshot).toHaveBeenCalledTimes(3);
});
github percy / react-percy / integration-tests / react-percy / __tests__ / basic-tests.js View on Github external
it('uploads CSS files', () => {
  expect(percy.uploadResource.mock.calls).toMatchSnapshot();
});
github percy / react-percy / integration-tests / react-percy / __tests__ / react-percy-tests.js View on Github external
const expectPercyToHaveRunSnapshots = () => {
  const expectedSnapshots = 6;

  expect(percy.createBuild).toHaveBeenCalledTimes(1);
  expect(percy.uploadResources).toHaveBeenCalledTimes(1);
  expect(percy.createSnapshot).toHaveBeenCalledTimes(expectedSnapshots);
  expect(percy.finalizeSnapshot).toHaveBeenCalledTimes(expectedSnapshots);
  expect(percy.finalizeBuild).toHaveBeenCalledTimes(1);
};
github percy / react-percy / integration-tests / react-percy / __tests__ / react-percy-tests.js View on Github external
beforeEach(() => {
  percy.createBuild.mockClear();
  percy.createSnapshot.mockClear();
  percy.finalizeBuild.mockClear();
  percy.finalizeSnapshot.mockClear();
  percy.uploadResources.mockClear();
});
github percy / react-percy / integration-tests / react-percy / __tests__ / react-percy-tests.js View on Github external
beforeEach(() => {
  percy.createBuild.mockClear();
  percy.createSnapshot.mockClear();
  percy.finalizeBuild.mockClear();
  percy.finalizeSnapshot.mockClear();
  percy.uploadResources.mockClear();
});
github percy / react-percy / integration-tests / react-percy / __tests__ / react-percy-tests.js View on Github external
const expectPercyToHaveRunSnapshots = () => {
  const expectedSnapshots = 6;

  expect(percy.createBuild).toHaveBeenCalledTimes(1);
  expect(percy.uploadResources).toHaveBeenCalledTimes(1);
  expect(percy.createSnapshot).toHaveBeenCalledTimes(expectedSnapshots);
  expect(percy.finalizeSnapshot).toHaveBeenCalledTimes(expectedSnapshots);
  expect(percy.finalizeBuild).toHaveBeenCalledTimes(1);
};
github percy / react-percy / integration-tests / react-percy / __tests__ / react-percy-tests.js View on Github external
beforeEach(() => {
  percy.createBuild.mockClear();
  percy.createSnapshot.mockClear();
  percy.finalizeBuild.mockClear();
  percy.finalizeSnapshot.mockClear();
  percy.uploadResources.mockClear();
});

percy-client

JavaScript API client library for Percy (https://percy.io).

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis

Similar packages