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

⬆️ Upgrade @percy/sdk-utils #214

Merged
merged 2 commits into from
Mar 26, 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"test:types": "tsd"
},
"dependencies": {
"@percy/sdk-utils": "~1.0.0-beta.32"
"@percy/sdk-utils": "~1.0.0-beta.44"
},
"peerDependencies": {
"nightmare": "~3"
},
"devDependencies": {
"@percy/core": "~1.0.0-beta.32",
"@percy/core": "~1.0.0-beta.44",
"@types/nightmare": "^2.10.4",
"cross-env": "^7.0.2",
"eslint": "^7.11.0",
Expand Down
48 changes: 24 additions & 24 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect');
const Nightmare = require('nightmare');
const sdk = require('@percy/sdk-utils/test/helper');
const helpers = require('@percy/sdk-utils/test/helpers');
const percySnapshot = require('..');

// xvfb wrapper
Expand All @@ -22,23 +22,23 @@ describe('percySnapshot', () => {
this.timeout(0);
await xvfb.start();
nightmare = new Nightmare();
await sdk.testsite.mock();
await helpers.mockSite();
});

after(async () => {
await sdk.testsite.close();
await helpers.closeSite();
await nightmare.end();
await xvfb.stop();
});

beforeEach(async function() {
this.timeout(0);
await sdk.setup();
await helpers.setup();
await nightmare.goto('http://localhost:8000');
});

afterEach(async () => {
await sdk.teardown();
await helpers.teardown();
});

it('throws an error when a name is not provided', () => {
Expand All @@ -47,19 +47,19 @@ describe('percySnapshot', () => {
});

it('disables snapshots when the healthcheck fails', async () => {
sdk.test.failure('/percy/healthcheck');
await helpers.testFailure('/percy/healthcheck');

await nightmare
.use(percySnapshot('Snapshot 1'))
.use(percySnapshot('Snapshot 2'));

expect(sdk.server.requests).toEqual([
await expect(helpers.getRequests()).resolves.toEqual([
['/percy/healthcheck']
]);

expect(sdk.logger.stderr).toEqual([]);
expect(sdk.logger.stdout).toEqual([
'[percy] Percy is not running, disabling snapshots\n'
expect(helpers.logger.stderr).toEqual([]);
expect(helpers.logger.stdout).toEqual([
'[percy] Percy is not running, disabling snapshots'
]);
});

Expand All @@ -68,7 +68,7 @@ describe('percySnapshot', () => {
.use(percySnapshot('Snapshot 1'))
.use(percySnapshot('Snapshot 2'));

expect(sdk.server.requests).toEqual([
await expect(helpers.getRequests()).resolves.toEqual([
['/percy/healthcheck'],
['/percy/dom.js'],
['/percy/snapshot', {
Expand All @@ -83,35 +83,35 @@ describe('percySnapshot', () => {
})]
]);

expect(sdk.logger.stdout).toEqual([]);
expect(sdk.logger.stderr).toEqual([]);
expect(helpers.logger.stdout).toEqual([]);
expect(helpers.logger.stderr).toEqual([]);
});

it('handles snapshot failures', async () => {
sdk.test.failure('/percy/snapshot', 'failure');
await helpers.testFailure('/percy/snapshot', 'failure');

await nightmare
.use(percySnapshot('Snapshot 1'));

expect(sdk.logger.stdout).toEqual([]);
expect(sdk.logger.stderr).toEqual([
'[percy] Could not take DOM snapshot "Snapshot 1"\n',
'[percy] Error: failure\n'
expect(helpers.logger.stdout).toEqual([]);
expect(helpers.logger.stderr).toEqual([
'[percy] Could not take DOM snapshot "Snapshot 1"',
'[percy] Error: failure'
]);
});

it('handles eval errors', async () => {
sdk.serializeDOM = () => {
await helpers.testSerialize(() => {
throw new Error('serialize error');
};
});

await nightmare
.use(percySnapshot('Snapshot 1'));

expect(sdk.logger.stdout).toEqual([]);
expect(sdk.logger.stderr).toEqual([
'[percy] Could not take DOM snapshot "Snapshot 1"\n',
'[percy] Error: serialize error\n'
expect(helpers.logger.stdout).toEqual([]);
expect(helpers.logger.stderr).toEqual([
'[percy] Could not take DOM snapshot "Snapshot 1"',
'[percy] Error: serialize error'
]);
});
});
70 changes: 35 additions & 35 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -240,61 +240,61 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@percy/client@^1.0.0-beta.39":
version "1.0.0-beta.39"
resolved "https://registry.yarnpkg.com/@percy/client/-/client-1.0.0-beta.39.tgz#b275258d7f9ae0453a7d1a3242320b7dc2a5ec6a"
integrity sha512-lFQp9zyku5p306RMFWoDVWob9pRkaJkpBO8MDPbNW3rxYEPhvQ/WyNSN1vqa18if0fOVYsA2ZpACkBaYVRjt1Q==
"@percy/client@^1.0.0-beta.44":
version "1.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@percy/client/-/client-1.0.0-beta.44.tgz#11214095e5697e6f2e0cbb8986945675abca2240"
integrity sha512-5jKcLr8BkAWp1gJYPA6fOts+nMIU+80dJGGg9HqVpp7KjeVzWNnr5y29Kjq0DHpB0aXUhnWNHpvI7pUvB3fzpg==
dependencies:
"@percy/env" "^1.0.0-beta.39"
"@percy/env" "^1.0.0-beta.44"

"@percy/config@^1.0.0-beta.39":
version "1.0.0-beta.39"
resolved "https://registry.yarnpkg.com/@percy/config/-/config-1.0.0-beta.39.tgz#96dc58f42200516f9a95b1c901ca41e98ffa5a59"
integrity sha512-Mnpo0xXtH2GOhUZmzqG4bT/r56eRYIkB9joAZ27JG2lHr597k4ZlmX0oz//Hnc4VQkMa9JvRfy66iQP+L2Oxiw==
"@percy/config@^1.0.0-beta.44":
version "1.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@percy/config/-/config-1.0.0-beta.44.tgz#6724032c331b5c3e06a7170941b24b6c155c63aa"
integrity sha512-qYf22C3wxzvxtA0lBAvJ7qWvvHYYU+Z9X2Gbl9rW/yXnxpglQTsMjUXA0NESRksOHjZ8vHV1nz7ei7E4Ua22eQ==
dependencies:
"@percy/logger" "^1.0.0-beta.39"
"@percy/logger" "^1.0.0-beta.44"
ajv "^7.0.3"
cosmiconfig "^7.0.0"
yaml "^1.10.0"

"@percy/core@~1.0.0-beta.32":
version "1.0.0-beta.39"
resolved "https://registry.yarnpkg.com/@percy/core/-/core-1.0.0-beta.39.tgz#317575658a333ada720904857e198ce2b2a7cd7c"
integrity sha512-jxwjgo42Rw0+x0E+M+OBgznXDjBTRfLPjuufw6LcsOrwPqxR4xShLiwbGaQvHZzLYzSPRGt9dqs1GauV0TZHNQ==
"@percy/core@~1.0.0-beta.44":
version "1.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@percy/core/-/core-1.0.0-beta.44.tgz#703753176a044c8dc110367dc2f0b09a3d463415"
integrity sha512-j6ebEmbt/ctWBZ15FtRVQQpjstQ4Pd3oEqUGcQvqalpxe/EkAlF56BTRgOzxYkNI0W5j57I0c9830aUSFs8aHw==
dependencies:
"@percy/client" "^1.0.0-beta.39"
"@percy/config" "^1.0.0-beta.39"
"@percy/dom" "^1.0.0-beta.39"
"@percy/logger" "^1.0.0-beta.39"
"@percy/client" "^1.0.0-beta.44"
"@percy/config" "^1.0.0-beta.44"
"@percy/dom" "^1.0.0-beta.44"
"@percy/logger" "^1.0.0-beta.44"
cross-spawn "^7.0.3"
extract-zip "^2.0.1"
progress "^2.0.3"
rimraf "^3.0.2"
ws "^7.4.1"

"@percy/dom@^1.0.0-beta.39":
version "1.0.0-beta.39"
resolved "https://registry.yarnpkg.com/@percy/dom/-/dom-1.0.0-beta.39.tgz#8923f90f910338362867aad2639951ec74c55112"
integrity sha512-9p4uFpyvHs1hNDJTMBFTWRtINPW1c1gaUHqblaov6zhr9/L/VUZx2xKFxBgl7Irvuw0osF0QhK5TjEWao6Qsqg==
"@percy/dom@^1.0.0-beta.44":
version "1.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@percy/dom/-/dom-1.0.0-beta.44.tgz#f0bdea9755789892028e79ecadd490dc9a5f0a88"
integrity sha512-ewwEk3oFM1f1Mh6peLwV0/tYJAH2gA5vN66EAbrL7rLC4JljxmlWpd/Bi3zbwxKYdTFEO3NBGJ/hKYRnjdbneg==

"@percy/env@^1.0.0-beta.39":
version "1.0.0-beta.39"
resolved "https://registry.yarnpkg.com/@percy/env/-/env-1.0.0-beta.39.tgz#d388615ee6260bbbe23b0220098340dd64edc755"
integrity sha512-s8T9wMmTDTavObSscknnni4qnZhfwQBbFFYwVD7ZTz7xtmu2ZqYWYIFuVOaB2so+AFRUv8shbGIcSgHWiXPZUg==
"@percy/env@^1.0.0-beta.44":
version "1.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@percy/env/-/env-1.0.0-beta.44.tgz#888503ecaefec36761d1d58a3c8a894ac86fe8cc"
integrity sha512-vU0uZGGPlfDYdkVToOYgJ2Nn84twW2hNx2r+a3t3DDT0w24YdlKRhwrOFaH7GVZlqe7bds8qfMHmVWGi4/KSSg==
dependencies:
dotenv "^8.2.0"

"@percy/logger@^1.0.0-beta.39":
version "1.0.0-beta.39"
resolved "https://registry.yarnpkg.com/@percy/logger/-/logger-1.0.0-beta.39.tgz#dd5c03866d0d494157be191237602d86d43de5ff"
integrity sha512-aEnKxCO3r9+bhxogIhJhxjh80QGImiIhbmik/oKCWNIc2KywATGRXsJvRmlF1DskA+RQcwzG/fENerSLNRycgQ==
"@percy/logger@^1.0.0-beta.44":
version "1.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@percy/logger/-/logger-1.0.0-beta.44.tgz#bd000b198ce7e09a134878c807011dadd4c2ce91"
integrity sha512-IUV2k/7oFHXp08jiJ6aNwwMJ3VN0sDYquurUBMkvwOrT12ww2Q9y38125xbiL+jXYLwkXBY+rSttA4wYvlKtIg==

"@percy/sdk-utils@~1.0.0-beta.32":
version "1.0.0-beta.39"
resolved "https://registry.yarnpkg.com/@percy/sdk-utils/-/sdk-utils-1.0.0-beta.39.tgz#3dcd5f5c80302cf3f791b7e1b038cb42b8779a42"
integrity sha512-/VdGp+2Q8g1NH/uBPhG/Txs16kuuUbo2mTos4yMAVCzjXFjIgdU8ydMhhss6hrbx5/cHHk9En+6EucIDoRdrig==
"@percy/sdk-utils@~1.0.0-beta.44":
version "1.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@percy/sdk-utils/-/sdk-utils-1.0.0-beta.44.tgz#acb76688bcfecfe53a44c2f5d3f86eea938630fa"
integrity sha512-iV0MNceYhROeIVKbHwbVgKFyEf/A+XmianA82v+IXBD5tawn9YfqKg5H5GjiaXhjLDYKwiYAMcM0X20njqKDcg==
dependencies:
"@percy/logger" "^1.0.0-beta.39"
"@percy/logger" "^1.0.0-beta.44"

"@sindresorhus/is@^0.14.0":
version "0.14.0"
Expand Down