build(deps): bump playwright from 1.49.1 to 1.50.1

This commit is contained in:
2025-02-21 17:22:03 -07:00
parent 79c9869e65
commit dc6d9c68a9
174 changed files with 3064 additions and 1955 deletions

View File

@@ -170,6 +170,7 @@ const customAsyncMatchers = {
toContainText: _matchers.toContainText,
toHaveAccessibleDescription: _matchers.toHaveAccessibleDescription,
toHaveAccessibleName: _matchers.toHaveAccessibleName,
toHaveAccessibleErrorMessage: _matchers.toHaveAccessibleErrorMessage,
toHaveAttribute: _matchers.toHaveAttribute,
toHaveClass: _matchers.toHaveClass,
toHaveCount: _matchers.toHaveCount,
@@ -234,9 +235,10 @@ class ExpectMetaInfoProxyHandler {
// out all the frames that belong to the test runner from caught runtime errors.
const stackFrames = (0, _util.filteredStackTrace)((0, _utils.captureRawStack)());
// Enclose toPass in a step to maintain async stacks, toPass matcher is always async.
// toPass and poll matchers can contain other steps, expects and API calls,
// so they behave like a retriable step.
const stepInfo = {
category: 'expect',
category: matcherName === 'toPass' || this._info.poll ? 'step' : 'expect',
title: (0, _util.trimLongString)(title, 1024),
params: args[0] ? {
expected: args[0]
@@ -248,6 +250,8 @@ class ExpectMetaInfoProxyHandler {
const jestError = (0, _matcherHint.isJestError)(e) ? e : null;
const error = jestError ? new _matcherHint.ExpectError(jestError, customMessage, stackFrames) : e;
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({
suggestedRebaseline: jestError === null || jestError === void 0 ? void 0 : jestError.matcherResult.suggestedRebaseline
});
@@ -263,12 +267,7 @@ class ExpectMetaInfoProxyHandler {
};
try {
const callback = () => matcher.call(target, ...args);
// toPass and poll matchers can contain other steps, expects and API calls,
// so they behave like a retriable step.
const result = matcherName === 'toPass' || this._info.poll ? _utils.zones.run('stepZone', step, callback) : _utils.zones.run('expectZone', {
title,
stepId: step.stepId
}, callback);
const result = _utils.zones.run('stepZone', step, callback);
if (result instanceof Promise) return result.then(finalizer).catch(reportStepError);
finalizer();
return result;

View File

@@ -16,6 +16,7 @@ exports.toBeOK = toBeOK;
exports.toBeVisible = toBeVisible;
exports.toContainText = toContainText;
exports.toHaveAccessibleDescription = toHaveAccessibleDescription;
exports.toHaveAccessibleErrorMessage = toHaveAccessibleErrorMessage;
exports.toHaveAccessibleName = toHaveAccessibleName;
exports.toHaveAttribute = toHaveAttribute;
exports.toHaveCSS = toHaveCSS;
@@ -58,9 +59,8 @@ var _config = require("../common/config");
function toBeAttached(locator, options) {
const attached = !options || options.attached === undefined || options.attached;
const expected = attached ? 'attached' : 'detached';
const unexpected = attached ? 'detached' : 'attached';
const arg = attached ? '' : '{ attached: false }';
return _toBeTruthy.toBeTruthy.call(this, 'toBeAttached', locator, 'Locator', expected, unexpected, arg, async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeAttached', locator, 'Locator', expected, arg, async (isNot, timeout) => {
return await locator._expect(attached ? 'to.be.attached' : 'to.be.detached', {
isNot,
timeout
@@ -68,19 +68,31 @@ function toBeAttached(locator, options) {
}, options);
}
function toBeChecked(locator, options) {
const checked = !options || options.checked === undefined || options.checked;
const expected = checked ? 'checked' : 'unchecked';
const unexpected = checked ? 'unchecked' : 'checked';
const arg = checked ? '' : '{ checked: false }';
return _toBeTruthy.toBeTruthy.call(this, 'toBeChecked', locator, 'Locator', expected, unexpected, arg, async (isNot, timeout) => {
return await locator._expect(checked ? 'to.be.checked' : 'to.be.unchecked', {
const checked = options === null || options === void 0 ? void 0 : options.checked;
const indeterminate = options === null || options === void 0 ? void 0 : options.indeterminate;
const expectedValue = {
checked,
indeterminate
};
let expected;
let arg;
if (options !== null && options !== void 0 && options.indeterminate) {
expected = 'indeterminate';
arg = `{ indeterminate: true }`;
} else {
expected = (options === null || options === void 0 ? void 0 : options.checked) === false ? 'unchecked' : 'checked';
arg = (options === null || options === void 0 ? void 0 : options.checked) === false ? `{ checked: false }` : '';
}
return _toBeTruthy.toBeTruthy.call(this, 'toBeChecked', locator, 'Locator', expected, arg, async (isNot, timeout) => {
return await locator._expect('to.be.checked', {
isNot,
timeout
timeout,
expectedValue
});
}, options);
}
function toBeDisabled(locator, options) {
return _toBeTruthy.toBeTruthy.call(this, 'toBeDisabled', locator, 'Locator', 'disabled', 'enabled', '', async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeDisabled', locator, 'Locator', 'disabled', '', async (isNot, timeout) => {
return await locator._expect('to.be.disabled', {
isNot,
timeout
@@ -90,9 +102,8 @@ function toBeDisabled(locator, options) {
function toBeEditable(locator, options) {
const editable = !options || options.editable === undefined || options.editable;
const expected = editable ? 'editable' : 'readOnly';
const unexpected = editable ? 'readOnly' : 'editable';
const arg = editable ? '' : '{ editable: false }';
return _toBeTruthy.toBeTruthy.call(this, 'toBeEditable', locator, 'Locator', expected, unexpected, arg, async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeEditable', locator, 'Locator', expected, arg, async (isNot, timeout) => {
return await locator._expect(editable ? 'to.be.editable' : 'to.be.readonly', {
isNot,
timeout
@@ -100,7 +111,7 @@ function toBeEditable(locator, options) {
}, options);
}
function toBeEmpty(locator, options) {
return _toBeTruthy.toBeTruthy.call(this, 'toBeEmpty', locator, 'Locator', 'empty', 'notEmpty', '', async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeEmpty', locator, 'Locator', 'empty', '', async (isNot, timeout) => {
return await locator._expect('to.be.empty', {
isNot,
timeout
@@ -110,9 +121,8 @@ function toBeEmpty(locator, options) {
function toBeEnabled(locator, options) {
const enabled = !options || options.enabled === undefined || options.enabled;
const expected = enabled ? 'enabled' : 'disabled';
const unexpected = enabled ? 'disabled' : 'enabled';
const arg = enabled ? '' : '{ enabled: false }';
return _toBeTruthy.toBeTruthy.call(this, 'toBeEnabled', locator, 'Locator', expected, unexpected, arg, async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeEnabled', locator, 'Locator', expected, arg, async (isNot, timeout) => {
return await locator._expect(enabled ? 'to.be.enabled' : 'to.be.disabled', {
isNot,
timeout
@@ -120,7 +130,7 @@ function toBeEnabled(locator, options) {
}, options);
}
function toBeFocused(locator, options) {
return _toBeTruthy.toBeTruthy.call(this, 'toBeFocused', locator, 'Locator', 'focused', 'inactive', '', async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeFocused', locator, 'Locator', 'focused', '', async (isNot, timeout) => {
return await locator._expect('to.be.focused', {
isNot,
timeout
@@ -128,7 +138,7 @@ function toBeFocused(locator, options) {
}, options);
}
function toBeHidden(locator, options) {
return _toBeTruthy.toBeTruthy.call(this, 'toBeHidden', locator, 'Locator', 'hidden', 'visible', '', async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeHidden', locator, 'Locator', 'hidden', '', async (isNot, timeout) => {
return await locator._expect('to.be.hidden', {
isNot,
timeout
@@ -138,9 +148,8 @@ function toBeHidden(locator, options) {
function toBeVisible(locator, options) {
const visible = !options || options.visible === undefined || options.visible;
const expected = visible ? 'visible' : 'hidden';
const unexpected = visible ? 'hidden' : 'visible';
const arg = visible ? '' : '{ visible: false }';
return _toBeTruthy.toBeTruthy.call(this, 'toBeVisible', locator, 'Locator', expected, unexpected, arg, async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeVisible', locator, 'Locator', expected, arg, async (isNot, timeout) => {
return await locator._expect(visible ? 'to.be.visible' : 'to.be.hidden', {
isNot,
timeout
@@ -148,7 +157,7 @@ function toBeVisible(locator, options) {
}, options);
}
function toBeInViewport(locator, options) {
return _toBeTruthy.toBeTruthy.call(this, 'toBeInViewport', locator, 'Locator', 'in viewport', 'outside viewport', '', async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toBeInViewport', locator, 'Locator', 'in viewport', '', async (isNot, timeout) => {
return await locator._expect('to.be.in.viewport', {
isNot,
expectedNumber: options === null || options === void 0 ? void 0 : options.ratio,
@@ -216,6 +225,19 @@ function toHaveAccessibleName(locator, expected, options) {
});
}, expected, options);
}
function toHaveAccessibleErrorMessage(locator, expected, options) {
return _toMatchText.toMatchText.call(this, 'toHaveAccessibleErrorMessage', locator, 'Locator', async (isNot, timeout) => {
const expectedText = (0, _utils.serializeExpectedTextValues)([expected], {
ignoreCase: options === null || options === void 0 ? void 0 : options.ignoreCase,
normalizeWhiteSpace: true
});
return await locator._expect('to.have.accessible.error.message', {
expectedText: expectedText,
isNot,
timeout
});
}, expected, options);
}
function toHaveAttribute(locator, name, expected, options) {
if (!options) {
// Update params for the case toHaveAttribute(name, options);
@@ -225,7 +247,7 @@ function toHaveAttribute(locator, name, expected, options) {
}
}
if (expected === undefined) {
return _toBeTruthy.toBeTruthy.call(this, 'toHaveAttribute', locator, 'Locator', 'have attribute', 'not have attribute', '', async (isNot, timeout) => {
return _toBeTruthy.toBeTruthy.call(this, 'toHaveAttribute', locator, 'Locator', 'have attribute', '', async (isNot, timeout) => {
return await locator._expect('to.have.attribute', {
expressionArg: name,
isNot,

View File

@@ -22,7 +22,7 @@ var _matcherHint = require("./matcherHint");
* limitations under the License.
*/
async function toBeTruthy(matcherName, receiver, receiverType, expected, unexpected, arg, query, options = {}) {
async function toBeTruthy(matcherName, receiver, receiverType, expected, arg, query, options = {}) {
var _options$timeout;
(0, _util.expectTypes)(receiver, [receiverType], matcherName);
const matcherOptions = {
@@ -45,7 +45,6 @@ async function toBeTruthy(matcherName, receiver, receiverType, expected, unexpec
};
}
const notFound = received === _matcherHint.kNoElementsFoundError ? received : undefined;
const actual = pass ? expected : unexpected;
let printedReceived;
let printedExpected;
if (pass) {
@@ -53,7 +52,7 @@ async function toBeTruthy(matcherName, receiver, receiverType, expected, unexpec
printedReceived = `Received: ${notFound ? _matcherHint.kNoElementsFoundError : expected}`;
} else {
printedExpected = `Expected: ${expected}`;
printedReceived = `Received: ${notFound ? _matcherHint.kNoElementsFoundError : unexpected}`;
printedReceived = `Received: ${notFound ? _matcherHint.kNoElementsFoundError : received}`;
}
const message = () => {
const header = (0, _matcherHint.matcherHint)(this, receiver, matcherName, 'locator', arg, matcherOptions, timedOut ? timeout : undefined);
@@ -63,7 +62,7 @@ async function toBeTruthy(matcherName, receiver, receiverType, expected, unexpec
return {
message,
pass,
actual,
actual: received,
name: matcherName,
expected,
log,

View File

@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
});
exports.toMatchAriaSnapshot = toMatchAriaSnapshot;
var _matcherHint = require("./matcherHint");
var _utilsBundle = require("playwright-core/lib/utilsBundle");
var _expectBundle = require("../common/expectBundle");
var _util = require("../util");
var _expect = require("./expect");
var _globals = require("../common/globals");
var _utils = require("playwright-core/lib/utils");
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright Microsoft Corporation. All rights reserved.
*
@@ -27,8 +29,8 @@ var _utils = require("playwright-core/lib/utils");
* limitations under the License.
*/
async function toMatchAriaSnapshot(receiver, expected, options = {}) {
var _options$timeout;
async function toMatchAriaSnapshot(receiver, expectedParam, options = {}) {
var _testInfo$_projectInt;
const matcherName = 'toMatchAriaSnapshot';
const testInfo = (0, _globals.currentTestInfo)();
if (!testInfo) throw new Error(`toMatchAriaSnapshot() must be called during the test`);
@@ -36,18 +38,41 @@ async function toMatchAriaSnapshot(receiver, expected, options = {}) {
pass: !this.isNot,
message: () => '',
name: 'toMatchAriaSnapshot',
expected
expected: ''
};
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 = {
isNot: this.isNot,
promise: this.promise
};
if (typeof expected !== 'string') {
throw new Error([(0, _matcherHint.matcherHint)(this, receiver, matcherName, receiver, expected, matcherOptions), `${_utilsBundle.colors.bold('Matcher error')}: ${(0, _expectBundle.EXPECTED_COLOR)('expected')} value must be a string`, this.utils.printWithType('Expected', expected, this.utils.printExpected)].join('\n\n'));
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._resolveSnapshotPath(pathTemplate, defaultTemplate, [(0, _util.sanitizeFilePathBeforeExtension)(expectedParam.name)]);
} else {
let snapshotNames = testInfo[snapshotNamesSymbol];
if (!snapshotNames) {
snapshotNames = {
anonymousSnapshotIndex: 0
};
testInfo[snapshotNamesSymbol] = snapshotNames;
}
const fullTitleWithoutSpec = [...testInfo.titlePath.slice(1), ++snapshotNames.anonymousSnapshotIndex].join(' ');
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;
}
const generateMissingBaseline = updateSnapshots === 'missing' && !expected;
const generateNewBaseline = updateSnapshots === 'all' || generateMissingBaseline;
if (generateMissingBaseline) {
if (this.isNot) {
const message = `Matchers using ".not" can't generate new baselines`;
@@ -61,7 +86,6 @@ async function toMatchAriaSnapshot(receiver, expected, options = {}) {
expected = `- none "Generating new baseline"`;
}
}
const timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : this.timeout;
expected = unshift(expected);
const {
matches: pass,
@@ -96,15 +120,46 @@ async function toMatchAriaSnapshot(receiver, expected, options = {}) {
return messagePrefix + this.utils.printDiffOrStringify(expected, receivedText, labelExpected, 'Received', false) + (0, _util.callLogText)(log);
}
};
if (!this.isNot && pass === this.isNot && generateNewBaseline) {
// Only rebaseline failed snapshots.
const suggestedRebaseline = `toMatchAriaSnapshot(\`\n${(0, _utils.escapeTemplateString)(indent(typedReceived.regex, '{indent} '))}\n{indent}\`)`;
return {
pass: this.isNot,
message: () => '',
name: 'toMatchAriaSnapshot',
suggestedRebaseline
};
if (!this.isNot) {
if (updateSnapshots === 'all' || updateSnapshots === 'changed' && pass === this.isNot || generateMissingBaseline) {
if (expectedPath) {
await _fs.default.promises.mkdir(_path.default.dirname(expectedPath), {
recursive: true
});
await _fs.default.promises.writeFile(expectedPath, typedReceived.regex, 'utf8');
const relativePath = _path.default.relative(process.cwd(), expectedPath);
if (updateSnapshots === 'missing') {
const message = `A snapshot doesn't exist at ${relativePath}, writing actual.`;
testInfo._hasNonRetriableError = true;
testInfo._failWithError(new Error(message));
} else {
const message = `A snapshot is generated at ${relativePath}.`;
/* eslint-disable no-console */
console.log(message);
}
return {
pass: true,
message: () => '',
name: 'toMatchAriaSnapshot'
};
} else {
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 {
pass: false,
message: () => '',
name: 'toMatchAriaSnapshot',
suggestedRebaseline
};
}
}
}
return {
name: matcherName,
@@ -123,10 +178,10 @@ function unshift(snapshot) {
if (!line.trim()) continue;
const match = line.match(/^(\s*)/);
if (match && match[1].length < whitespacePrefixLength) whitespacePrefixLength = match[1].length;
break;
}
return lines.filter(t => t.trim()).map(line => line.substring(whitespacePrefixLength)).join('\n');
}
function indent(snapshot, indent) {
return snapshot.split('\n').map(line => indent + line).join('\n');
}
}
const snapshotNamesSymbol = Symbol('snapshotNames');

View File

@@ -102,7 +102,8 @@ class SnapshotHelper {
outputBasePath = testInfo._getOutputPath(sanitizedName);
this.attachmentBaseName = sanitizedName;
}
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');
this.previousPath = (0, _util.addSuffixToFilePath)(outputBasePath, '-previous');
this.actualPath = (0, _util.addSuffixToFilePath)(outputBasePath, '-actual');
@@ -144,7 +145,7 @@ class SnapshotHelper {
return Object.fromEntries(Object.entries(unfiltered).filter(([_, v]) => v !== undefined));
}
handleMissingNegated() {
const isWriteMissingMode = this.updateSnapshots === 'all' || this.updateSnapshots === 'missing';
const isWriteMissingMode = this.updateSnapshots !== 'none';
const message = `A snapshot doesn't exist at ${this.expectedPath}${isWriteMissingMode ? ', matchers using ".not" won\'t write them automatically.' : '.'}`;
// NOTE: 'isNot' matcher implies inversed value.
return this.createMatcherResult(message, true);
@@ -159,7 +160,7 @@ class SnapshotHelper {
return this.createMatcherResult(message, true);
}
handleMissing(actual) {
const isWriteMissingMode = this.updateSnapshots === 'all' || this.updateSnapshots === 'missing';
const isWriteMissingMode = this.updateSnapshots !== 'none';
if (isWriteMissingMode) writeFileSync(this.expectedPath, actual);
this.testInfo.attachments.push({
name: (0, _util.addSuffixToFilePath)(this.attachmentBaseName, '-expected'),
@@ -173,7 +174,7 @@ class SnapshotHelper {
path: this.actualPath
});
const message = `A snapshot doesn't exist at ${this.expectedPath}${isWriteMissingMode ? ', writing actual.' : '.'}`;
if (this.updateSnapshots === 'all') {
if (this.updateSnapshots === 'all' || this.updateSnapshots === 'changed') {
/* eslint-disable no-console */
console.log(message);
return this.createMatcherResult(message, true);
@@ -252,14 +253,23 @@ function toMatchSnapshot(received, nameOrOptions = {}, optOptions = {}) {
}
if (!_fs.default.existsSync(helper.expectedPath)) return helper.handleMissing(received);
const expected = _fs.default.readFileSync(helper.expectedPath);
const result = helper.comparator(received, expected, helper.options);
if (!result) return helper.handleMatching();
if (helper.updateSnapshots === 'all') {
if (!(0, _utils.compareBuffersOrStrings)(received, expected)) return helper.handleMatching();
writeFileSync(helper.expectedPath, received);
/* eslint-disable no-console */
console.log(helper.expectedPath + ' is not the same, writing actual.');
return helper.createMatcherResult(helper.expectedPath + ' running with --update-snapshots, writing actual.', true);
}
if (helper.updateSnapshots === 'changed') {
const result = helper.comparator(received, expected, helper.options);
if (!result) return helper.handleMatching();
writeFileSync(helper.expectedPath, received);
/* eslint-disable no-console */
console.log(helper.expectedPath + ' does not match, writing actual.');
return helper.createMatcherResult(helper.expectedPath + ' running with --update-snapshots, writing actual.', true);
}
const result = helper.comparator(received, expected, helper.options);
if (!result) return helper.handleMatching();
const receiver = (0, _utils.isString)(received) ? 'string' : 'Buffer';
const header = (0, _matcherHint.matcherHint)(this, undefined, 'toMatchSnapshot', receiver, undefined, undefined);
return helper.handleDifferent(received, expected, undefined, result.diff, header, result.errorMessage, undefined);
@@ -344,8 +354,8 @@ async function toHaveScreenshot(pageOrLocator, nameOrOptions = {}, optOptions =
// General case:
// - snapshot exists
// - regular matcher (i.e. not a `.not`)
// - perhaps an 'all' flag to update non-matching screenshots
expectScreenshotOptions.expected = await _fs.default.promises.readFile(helper.expectedPath);
const expected = await _fs.default.promises.readFile(helper.expectedPath);
expectScreenshotOptions.expected = helper.updateSnapshots === 'all' ? undefined : expected;
const {
actual,
previous,
@@ -354,14 +364,22 @@ async function toHaveScreenshot(pageOrLocator, nameOrOptions = {}, optOptions =
log,
timedOut
} = await page._expectScreenshot(expectScreenshotOptions);
if (!errorMessage) return helper.handleMatching();
if (helper.updateSnapshots === 'all') {
const writeFiles = () => {
writeFileSync(helper.expectedPath, actual);
writeFileSync(helper.actualPath, actual);
/* eslint-disable no-console */
console.log(helper.expectedPath + ' is re-generated, writing actual.');
return helper.createMatcherResult(helper.expectedPath + ' running with --update-snapshots, writing actual.', true);
};
if (!errorMessage) {
// Screenshot is matching, but is not necessarily the same as the expected.
if (helper.updateSnapshots === 'all' && actual && (0, _utils.compareBuffersOrStrings)(actual, expected)) {
console.log(helper.expectedPath + ' is re-generated, writing actual.');
return writeFiles();
}
return helper.handleMatching();
}
if (helper.updateSnapshots === 'changed' || helper.updateSnapshots === 'all') return writeFiles();
const header = (0, _matcherHint.matcherHint)(this, undefined, 'toHaveScreenshot', receiver, undefined, undefined, timedOut ? timeout : undefined);
return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header, errorMessage, log);
}