playwright
Advanced tools
Comparing version
@@ -164,4 +164,3 @@ "use strict"; | ||
const testDir = takeFirst(pathResolve(configDir, projectConfig.testDir), pathResolve(configDir, config.testDir), fullConfig.configDir); | ||
const defaultSnapshotPathTemplate = '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{-snapshotSuffix}{ext}'; | ||
this.snapshotPathTemplate = takeFirst(projectConfig.snapshotPathTemplate, config.snapshotPathTemplate, defaultSnapshotPathTemplate); | ||
this.snapshotPathTemplate = takeFirst(projectConfig.snapshotPathTemplate, config.snapshotPathTemplate); | ||
this.project = { | ||
@@ -168,0 +167,0 @@ grep: takeFirst(projectConfig.grep, config.grep, defaultGrep), |
@@ -209,3 +209,3 @@ "use strict"; | ||
if ('updateSnapshots' in config && config.updateSnapshots !== undefined) { | ||
if (typeof config.updateSnapshots !== 'string' || !['all', 'none', 'missing'].includes(config.updateSnapshots)) throw (0, _util.errorWithFile)(file, `config.updateSnapshots must be one of "all", "none" or "missing"`); | ||
if (typeof config.updateSnapshots !== 'string' || !['all', 'changed', 'missing', 'none'].includes(config.updateSnapshots)) throw (0, _util.errorWithFile)(file, `config.updateSnapshots must be one of "all", "changed", "missing" or "none"`); | ||
} | ||
@@ -212,0 +212,0 @@ if ('workers' in config && config.workers !== undefined) { |
@@ -253,2 +253,4 @@ "use strict"; | ||
if (jestError !== null && jestError !== void 0 && jestError.matcherResult.suggestedRebaseline) { | ||
// NOTE: this is a workaround for the fact that we can't pass the suggested rebaseline | ||
// for passing matchers. See toMatchAriaSnapshot for a counterpart. | ||
step.complete({ | ||
@@ -255,0 +257,0 @@ suggestedRebaseline: jestError === null || jestError === void 0 ? void 0 : jestError.matcherResult.suggestedRebaseline |
@@ -33,3 +33,3 @@ "use strict"; | ||
async function toMatchAriaSnapshot(receiver, expectedParam, options = {}) { | ||
var _options$timeout; | ||
var _testInfo$_projectInt; | ||
const matcherName = 'toMatchAriaSnapshot'; | ||
@@ -45,2 +45,4 @@ const testInfo = (0, _globals.currentTestInfo)(); | ||
const updateSnapshots = testInfo.config.updateSnapshots; | ||
const pathTemplate = (_testInfo$_projectInt = testInfo._projectInternal.expect) === null || _testInfo$_projectInt === void 0 || (_testInfo$_projectInt = _testInfo$_projectInt.toMatchAriaSnapshot) === null || _testInfo$_projectInt === void 0 ? void 0 : _testInfo$_projectInt.pathTemplate; | ||
const defaultTemplate = '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{ext}'; | ||
const matcherOptions = { | ||
@@ -51,8 +53,12 @@ isNot: this.isNot, | ||
let expected; | ||
let timeout; | ||
let expectedPath; | ||
if ((0, _utils.isString)(expectedParam)) { | ||
var _options$timeout; | ||
expected = expectedParam; | ||
timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : this.timeout; | ||
} else { | ||
var _expectedParam$timeou; | ||
if (expectedParam !== null && expectedParam !== void 0 && expectedParam.name) { | ||
expectedPath = testInfo.snapshotPath((0, _util.sanitizeFilePathBeforeExtension)(expectedParam.name)); | ||
expectedPath = testInfo._resolveSnapshotPath(pathTemplate, defaultTemplate, [(0, _util.sanitizeFilePathBeforeExtension)(expectedParam.name)]); | ||
} else { | ||
@@ -67,5 +73,6 @@ let snapshotNames = testInfo[snapshotNamesSymbol]; | ||
const fullTitleWithoutSpec = [...testInfo.titlePath.slice(1), ++snapshotNames.anonymousSnapshotIndex].join(' '); | ||
expectedPath = testInfo.snapshotPath((0, _utils.sanitizeForFilePath)((0, _util.trimLongString)(fullTitleWithoutSpec)) + '.yml'); | ||
expectedPath = testInfo._resolveSnapshotPath(pathTemplate, defaultTemplate, [(0, _utils.sanitizeForFilePath)((0, _util.trimLongString)(fullTitleWithoutSpec)) + '.yml']); | ||
} | ||
expected = await _fs.default.promises.readFile(expectedPath, 'utf8').catch(() => ''); | ||
timeout = (_expectedParam$timeou = expectedParam === null || expectedParam === void 0 ? void 0 : expectedParam.timeout) !== null && _expectedParam$timeou !== void 0 ? _expectedParam$timeou : this.timeout; | ||
} | ||
@@ -86,3 +93,2 @@ const generateMissingBaseline = updateSnapshots === 'missing' && !expected; | ||
} | ||
const timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : this.timeout; | ||
expected = unshift(expected); | ||
@@ -146,2 +152,10 @@ const { | ||
const suggestedRebaseline = `\`\n${(0, _utils.escapeTemplateString)(indent(typedReceived.regex, '{indent} '))}\n{indent}\``; | ||
if (updateSnapshots === 'missing') { | ||
const message = 'A snapshot is not provided, generating new baseline.'; | ||
testInfo._hasNonRetriableError = true; | ||
testInfo._failWithError(new Error(message)); | ||
} | ||
// TODO: ideally, we should return "pass: true" here because this matcher passes | ||
// when regenerating baselines. However, we can only access suggestedRebaseline in case | ||
// of an error, so we fail here and workaround it in the expect implementation. | ||
return { | ||
@@ -148,0 +162,0 @@ pass: false, |
@@ -105,3 +105,4 @@ "use strict"; | ||
} | ||
this.expectedPath = testInfo.snapshotPath(...expectedPathSegments); | ||
const defaultTemplate = '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{-snapshotSuffix}{ext}'; | ||
this.expectedPath = testInfo._resolveSnapshotPath(configOptions.pathTemplate, defaultTemplate, expectedPathSegments); | ||
this.legacyExpectedPath = (0, _util.addSuffixToFilePath)(outputBasePath, '-expected'); | ||
@@ -108,0 +109,0 @@ this.previousPath = (0, _util.addSuffixToFilePath)(outputBasePath, '-previous'); |
@@ -272,3 +272,3 @@ "use strict"; | ||
let updateSnapshots; | ||
if (['all', 'changed', 'missing', 'none'].includes(options.updateSnapshots)) updateSnapshots = options.updateSnapshots;else updateSnapshots = 'updateSnapshots' in options ? 'changed' : 'missing'; | ||
if (['all', 'changed', 'missing', 'none'].includes(options.updateSnapshots)) updateSnapshots = options.updateSnapshots;else updateSnapshots = 'updateSnapshots' in options ? 'changed' : undefined; | ||
const overrides = { | ||
@@ -275,0 +275,0 @@ forbidOnly: options.forbidOnly ? true : undefined, |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.applySuggestedRebaselines = applySuggestedRebaselines; | ||
exports.clearSuggestedRebaselines = clearSuggestedRebaselines; | ||
var _path = _interopRequireDefault(require("path")); | ||
@@ -40,2 +41,5 @@ var _fs = _interopRequireDefault(require("fs")); | ||
} | ||
function clearSuggestedRebaselines() { | ||
suggestedRebaselines.clear(); | ||
} | ||
async function applySuggestedRebaselines(config, reporter) { | ||
@@ -42,0 +46,0 @@ if (config.config.updateSnapshots === 'none') return; |
@@ -270,2 +270,5 @@ "use strict"; | ||
title: 'apply rebaselines', | ||
setup: async () => { | ||
(0, _rebase.clearSuggestedRebaselines)(); | ||
}, | ||
teardown: async ({ | ||
@@ -272,0 +275,0 @@ config, |
@@ -386,3 +386,3 @@ "use strict"; | ||
} | ||
snapshotPath(...pathSegments) { | ||
_resolveSnapshotPath(template, defaultTemplate, pathSegments) { | ||
const subPath = _path.default.join(...pathSegments); | ||
@@ -393,5 +393,10 @@ const parsedSubPath = _path.default.parse(subPath); | ||
const projectNamePathSegment = (0, _utils.sanitizeForFilePath)(this.project.name); | ||
const snapshotPath = (this._projectInternal.snapshotPathTemplate || '').replace(/\{(.)?testDir\}/g, '$1' + this.project.testDir).replace(/\{(.)?snapshotDir\}/g, '$1' + this.project.snapshotDir).replace(/\{(.)?snapshotSuffix\}/g, this.snapshotSuffix ? '$1' + this.snapshotSuffix : '').replace(/\{(.)?testFileDir\}/g, '$1' + parsedRelativeTestFilePath.dir).replace(/\{(.)?platform\}/g, '$1' + process.platform).replace(/\{(.)?projectName\}/g, projectNamePathSegment ? '$1' + projectNamePathSegment : '').replace(/\{(.)?testName\}/g, '$1' + this._fsSanitizedTestName()).replace(/\{(.)?testFileName\}/g, '$1' + parsedRelativeTestFilePath.base).replace(/\{(.)?testFilePath\}/g, '$1' + relativeTestFilePath).replace(/\{(.)?arg\}/g, '$1' + _path.default.join(parsedSubPath.dir, parsedSubPath.name)).replace(/\{(.)?ext\}/g, parsedSubPath.ext ? '$1' + parsedSubPath.ext : ''); | ||
const actualTemplate = template || this._projectInternal.snapshotPathTemplate || defaultTemplate; | ||
const snapshotPath = actualTemplate.replace(/\{(.)?testDir\}/g, '$1' + this.project.testDir).replace(/\{(.)?snapshotDir\}/g, '$1' + this.project.snapshotDir).replace(/\{(.)?snapshotSuffix\}/g, this.snapshotSuffix ? '$1' + this.snapshotSuffix : '').replace(/\{(.)?testFileDir\}/g, '$1' + parsedRelativeTestFilePath.dir).replace(/\{(.)?platform\}/g, '$1' + process.platform).replace(/\{(.)?projectName\}/g, projectNamePathSegment ? '$1' + projectNamePathSegment : '').replace(/\{(.)?testName\}/g, '$1' + this._fsSanitizedTestName()).replace(/\{(.)?testFileName\}/g, '$1' + parsedRelativeTestFilePath.base).replace(/\{(.)?testFilePath\}/g, '$1' + relativeTestFilePath).replace(/\{(.)?arg\}/g, '$1' + _path.default.join(parsedSubPath.dir, parsedSubPath.name)).replace(/\{(.)?ext\}/g, parsedSubPath.ext ? '$1' + parsedSubPath.ext : ''); | ||
return _path.default.normalize(_path.default.resolve(this._configInternal.configDir, snapshotPath)); | ||
} | ||
snapshotPath(...pathSegments) { | ||
const legacyTemplate = '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{-snapshotSuffix}{ext}'; | ||
return this._resolveSnapshotPath(undefined, legacyTemplate, pathSegments); | ||
} | ||
skip(...args) { | ||
@@ -398,0 +403,0 @@ this._modifier('skip', args); |
{ | ||
"name": "playwright", | ||
"version": "1.50.0", | ||
"version": "1.50.1-beta-1738339353000", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -59,3 +59,3 @@ "repository": { | ||
"dependencies": { | ||
"playwright-core": "1.50.0" | ||
"playwright-core": "1.50.1-beta-1738339353000" | ||
}, | ||
@@ -62,0 +62,0 @@ "optionalDependencies": { |
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3178988
0.16%36357
0.28%3
50%+ Added
- Removed