playwright
Advanced tools
Comparing version
@@ -170,4 +170,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 = { | ||
@@ -174,0 +173,0 @@ grep: takeFirst(projectConfig.grep, config.grep, defaultGrep), |
@@ -33,2 +33,3 @@ "use strict"; | ||
async function toMatchAriaSnapshot(receiver, expectedParam, options = {}) { | ||
var _testInfo$_projectInt; | ||
const matcherName = 'toMatchAriaSnapshot'; | ||
@@ -44,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 = { | ||
@@ -59,3 +62,3 @@ isNot: this.isNot, | ||
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 { | ||
@@ -70,3 +73,3 @@ 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']); | ||
} | ||
@@ -73,0 +76,0 @@ expected = await _fs.default.promises.readFile(expectedPath, 'utf8').catch(() => ''); |
@@ -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'); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.gitStatusFromCLI = exports.gitCommitInfo = exports.addGitCommitInfoPlugin = void 0; | ||
exports.gitCommitInfo = exports.addGitCommitInfoPlugin = void 0; | ||
var _utils = require("playwright-core/lib/utils"); | ||
@@ -36,12 +36,11 @@ /** | ||
setup: async (config, configDir) => { | ||
const fromEnv = linksFromEnv(); | ||
const fromCLI = await gitStatusFromCLI((options === null || options === void 0 ? void 0 : options.directory) || configDir); | ||
const info = { | ||
...linksFromEnv(), | ||
...(options !== null && options !== void 0 && options.info ? options.info : await gitStatusFromCLI((options === null || options === void 0 ? void 0 : options.directory) || configDir)), | ||
timestamp: Date.now() | ||
...fromEnv, | ||
...fromCLI | ||
}; | ||
// Normalize dates | ||
const timestamp = info['revision.timestamp']; | ||
if (timestamp instanceof Date) info['revision.timestamp'] = timestamp.getTime(); | ||
if (info['revision.timestamp'] instanceof Date) info['revision.timestamp'] = info['revision.timestamp'].getTime(); | ||
config.metadata = config.metadata || {}; | ||
Object.assign(config.metadata, info); | ||
config.metadata['git.commit.info'] = info; | ||
} | ||
@@ -51,3 +50,3 @@ }; | ||
exports.gitCommitInfo = gitCommitInfo; | ||
const linksFromEnv = () => { | ||
function linksFromEnv() { | ||
const out = {}; | ||
@@ -63,4 +62,4 @@ // Jenkins: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables | ||
return out; | ||
}; | ||
const gitStatusFromCLI = async gitDir => { | ||
} | ||
async function gitStatusFromCLI(gitDir) { | ||
const separator = `:${(0, _utils.createGuid)().slice(0, 4)}:`; | ||
@@ -87,3 +86,2 @@ const { | ||
}; | ||
}; | ||
exports.gitStatusFromCLI = gitStatusFromCLI; | ||
} |
@@ -67,6 +67,6 @@ "use strict"; | ||
onStepBegin(test, result, step) { | ||
if (step.category === 'test.step') this._updateLine(test, result, step); | ||
if (this.screen.isTTY && step.category === 'test.step') this._updateLine(test, result, step); | ||
} | ||
onStepEnd(test, result, step) { | ||
if (step.category === 'test.step') this._updateLine(test, result, step.parent); | ||
if (this.screen.isTTY && step.category === 'test.step') this._updateLine(test, result, step.parent); | ||
} | ||
@@ -73,0 +73,0 @@ onTestEnd(test, result) { |
@@ -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.51.0-alpha-2025-01-29", | ||
"version": "1.51.0-alpha-2025-01-30", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -59,3 +59,3 @@ "repository": { | ||
"dependencies": { | ||
"playwright-core": "1.51.0-alpha-2025-01-29" | ||
"playwright-core": "1.51.0-alpha-2025-01-30" | ||
}, | ||
@@ -62,0 +62,0 @@ "optionalDependencies": { |
Sorry, the diff of this file is too big to display
3185174
0.14%36492
0.24%+ Added
- Removed