@percy/core
Advanced tools
Comparing version 1.28.1-alpha.2 to 1.28.1-alpha.3
@@ -74,2 +74,5 @@ // Common config options used in Percy commands | ||
}, | ||
testCase: { | ||
type: 'string' | ||
}, | ||
fullPage: { | ||
@@ -320,2 +323,5 @@ type: 'boolean', | ||
}, | ||
testCase: { | ||
$ref: '/config/snapshot#/properties/testCase' | ||
}, | ||
reshuffleInvalidTags: { | ||
@@ -322,0 +328,0 @@ $ref: '/config/snapshot#/properties/reshuffleInvalidTags' |
import logger from '@percy/logger'; | ||
import Queue from './queue.js'; | ||
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, withRetries } from './utils.js'; | ||
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, snapshotLogName, withRetries } from './utils.js'; | ||
@@ -142,4 +142,4 @@ // Logs verbose debug logs detailing various snapshot options. | ||
resources.push(createLogResource(logger.query(log => { | ||
var _log$meta$snapshot; | ||
return ((_log$meta$snapshot = log.meta.snapshot) === null || _log$meta$snapshot === void 0 ? void 0 : _log$meta$snapshot.name) === snapshot.meta.snapshot.name; | ||
var _log$meta$snapshot, _log$meta$snapshot2; | ||
return ((_log$meta$snapshot = log.meta.snapshot) === null || _log$meta$snapshot === void 0 ? void 0 : _log$meta$snapshot.testCase) === snapshot.meta.snapshot.testCase && ((_log$meta$snapshot2 = log.meta.snapshot) === null || _log$meta$snapshot2 === void 0 ? void 0 : _log$meta$snapshot2.name) === snapshot.meta.snapshot.name; | ||
}))); | ||
@@ -301,7 +301,8 @@ return { | ||
}) | ||
// snapshots are unique by name; when deferred also by widths | ||
// snapshots are unique by name and testCase; when deferred also by widths | ||
.handle('find', ({ | ||
name, | ||
testCase, | ||
widths | ||
}, snapshot) => snapshot.name === name && (!percy.deferUploads || !widths || widths.join() === snapshot.widths.join())) | ||
}, snapshot) => snapshot.testCase === testCase && snapshot.name === name && (!percy.deferUploads || !widths || widths.join() === snapshot.widths.join())) | ||
// initialize the resources for DOM snapshots | ||
@@ -360,4 +361,6 @@ .handle('push', snapshot => { | ||
onRetry: () => { | ||
percy.log.debug(`Retrying snapshot: ${snapshot.name}`, snapshot.meta); | ||
} | ||
percy.log.info(`Retrying snapshot: ${snapshotLogName(snapshot.name, snapshot.meta)}`, snapshot.meta); | ||
}, | ||
signal: snapshot._ctrl.signal, | ||
throwOn: ['AbortError'] | ||
}); | ||
@@ -370,3 +373,3 @@ }).handle('error', ({ | ||
// only error about aborted snapshots when not closed | ||
percy.log.error('Received a duplicate snapshot, ' + `the previous snapshot was aborted: ${name}`, meta); | ||
percy.log.error('Received a duplicate snapshot, ' + `the previous snapshot was aborted: ${snapshotLogName(name, meta)}`, meta); | ||
} else { | ||
@@ -373,0 +376,0 @@ // log all other encountered errors |
@@ -125,5 +125,11 @@ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } | ||
let exists = this.cancel(item); | ||
task.ctrl = new AbortController(); | ||
// duplicate abortion controller on task, so it can can be used in further | ||
// generators and can be cancelled internally | ||
// TODO fix this for non object item usecase | ||
if (typeof item === 'object' && !Array.isArray(item) && item !== null) { | ||
item._ctrl = task.ctrl; | ||
} | ||
task.item = item = _classPrivateFieldGet(this, _handlers).push ? _classPrivateFieldGet(this, _handlers).push(item, exists) : item; | ||
task.handler = () => _classPrivateFieldGet(this, _handlers).task ? _classPrivateFieldGet(this, _handlers).task(item, ...args) : item; | ||
task.ctrl = new AbortController(); | ||
@@ -130,0 +136,0 @@ // queue this task & maybe dequeue the next task |
@@ -6,3 +6,3 @@ import logger from '@percy/logger'; | ||
import Queue from './queue.js'; | ||
import { request, hostnameMatches, yieldTo } from './utils.js'; | ||
import { request, hostnameMatches, yieldTo, snapshotLogName } from './utils.js'; | ||
import { JobData } from './wait-for-job.js'; | ||
@@ -117,3 +117,4 @@ | ||
snapshot: { | ||
name: options.name | ||
name: options.name, | ||
testCase: options.testCase | ||
} | ||
@@ -396,6 +397,7 @@ } | ||
}) | ||
// snapshots are unique by name alone | ||
// snapshots are unique by name and testCase both | ||
.handle('find', ({ | ||
name | ||
}, snapshot) => snapshot.name === name) | ||
name, | ||
testCase | ||
}, snapshot) => snapshot.testCase === testCase && snapshot.name === name) | ||
// when pushed, maybe flush old snapshots or possibly merge with existing snapshots | ||
@@ -409,4 +411,4 @@ .handle('push', (snapshot, existing) => { | ||
// log immediately when not deferred or dry-running | ||
if (!percy.deferUploads) percy.log.info(`Snapshot taken: ${name}`, meta); | ||
if (percy.dryRun) percy.log.info(`Snapshot found: ${name}`, meta); | ||
if (!percy.deferUploads) percy.log.info(`Snapshot taken: ${snapshotLogName(name, meta)}`, meta); | ||
if (percy.dryRun) percy.log.info(`Snapshot found: ${snapshotLogName(name, meta)}`, meta); | ||
@@ -413,0 +415,0 @@ // immediately flush when uploads are delayed but not skipped |
@@ -333,3 +333,5 @@ import EventEmitter from 'events'; | ||
count, | ||
onRetry | ||
onRetry, | ||
signal, | ||
throwOn | ||
}) { | ||
@@ -341,5 +343,7 @@ count || (count = 1); // default a single try | ||
try { | ||
return await generatePromise(fn); | ||
return await generatePromise(fn, signal); | ||
} catch (e) { | ||
if (run < count) { | ||
// if this error should not be retried on, we want to skip errors | ||
let throwError = throwOn === null || throwOn === void 0 ? void 0 : throwOn.includes(e.name); | ||
if (!throwError && run < count) { | ||
await (onRetry === null || onRetry === void 0 ? void 0 : onRetry()); | ||
@@ -352,2 +356,9 @@ continue; | ||
} | ||
export function snapshotLogName(name, meta) { | ||
var _meta$snapshot; | ||
if (meta !== null && meta !== void 0 && (_meta$snapshot = meta.snapshot) !== null && _meta$snapshot !== void 0 && _meta$snapshot.testCase) { | ||
return `testCase: ${meta.snapshot.testCase}, ${name}`; | ||
} | ||
return name; | ||
} | ||
@@ -354,0 +365,0 @@ // DefaultMap, which returns a default value for an uninitialized key |
{ | ||
"name": "@percy/core", | ||
"version": "1.28.1-alpha.2", | ||
"version": "1.28.1-alpha.3", | ||
"license": "MIT", | ||
@@ -46,7 +46,7 @@ "repository": { | ||
"dependencies": { | ||
"@percy/client": "1.28.1-alpha.2", | ||
"@percy/config": "1.28.1-alpha.2", | ||
"@percy/dom": "1.28.1-alpha.2", | ||
"@percy/logger": "1.28.1-alpha.2", | ||
"@percy/webdriver-utils": "1.28.1-alpha.2", | ||
"@percy/client": "1.28.1-alpha.3", | ||
"@percy/config": "1.28.1-alpha.3", | ||
"@percy/dom": "1.28.1-alpha.3", | ||
"@percy/logger": "1.28.1-alpha.3", | ||
"@percy/webdriver-utils": "1.28.1-alpha.3", | ||
"content-disposition": "^0.5.4", | ||
@@ -62,3 +62,3 @@ "cross-spawn": "^7.0.3", | ||
}, | ||
"gitHead": "a3f2e709d0a6445e15a1128686578b1659243a95" | ||
"gitHead": "46d1e874e1092fee45899d70cd97cf793db17de5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202493
4895
240
3
11
0
72
+ Added@percy/client@1.28.1-alpha.3(transitive)
+ Added@percy/config@1.28.1-alpha.3(transitive)
+ Added@percy/dom@1.28.1-alpha.3(transitive)
+ Added@percy/env@1.28.1-alpha.3(transitive)
+ Added@percy/logger@1.28.1-alpha.3(transitive)
+ Added@percy/sdk-utils@1.28.1-alpha.3(transitive)
+ Added@percy/webdriver-utils@1.28.1-alpha.3(transitive)
- Removed@percy/client@1.28.1-alpha.2(transitive)
- Removed@percy/config@1.28.1-alpha.2(transitive)
- Removed@percy/dom@1.28.1-alpha.2(transitive)
- Removed@percy/env@1.28.1-alpha.2(transitive)
- Removed@percy/logger@1.28.1-alpha.2(transitive)
- Removed@percy/sdk-utils@1.28.1-alpha.2(transitive)
- Removed@percy/webdriver-utils@1.28.1-alpha.2(transitive)
Updated@percy/client@1.28.1-alpha.3
Updated@percy/config@1.28.1-alpha.3
Updated@percy/dom@1.28.1-alpha.3
Updated@percy/logger@1.28.1-alpha.3