Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

playwright

Package Overview
Dependencies
Maintainers
4
Versions
4633
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

playwright - npm Package Compare versions

Comparing version 1.49.0-alpha-2024-10-21 to 1.49.0-alpha-2024-10-22

lib/worker/util.js

33

lib/matchers/toBeTruthy.js

@@ -34,3 +34,3 @@ "use strict";

const {
matches,
matches: pass,
log,

@@ -40,12 +40,29 @@ timedOut,

} = await query(!!this.isNot, timeout);
if (pass === !this.isNot) {
return {
name: matcherName,
message: () => '',
pass,
expected
};
}
const notFound = received === _matcherHint.kNoElementsFoundError ? received : undefined;
const actual = matches ? expected : unexpected;
const actual = pass ? expected : unexpected;
let printedReceived;
let printedExpected;
if (pass) {
printedExpected = `Expected: not ${expected}`;
printedReceived = `Received: ${notFound ? _matcherHint.kNoElementsFoundError : expected}`;
} else {
printedExpected = `Expected: ${expected}`;
printedReceived = `Received: ${notFound ? _matcherHint.kNoElementsFoundError : unexpected}`;
}
const message = () => {
const header = (0, _matcherHint.matcherHint)(this, receiver, matcherName, 'locator', arg, matcherOptions, timedOut ? timeout : undefined);
const logText = (0, _util.callLogText)(log);
return matches ? `${header}Expected: not ${expected}\nReceived: ${notFound ? _matcherHint.kNoElementsFoundError : expected}${logText}` : `${header}Expected: ${expected}\nReceived: ${notFound ? _matcherHint.kNoElementsFoundError : unexpected}${logText}`;
return `${header}${printedExpected}\n${printedReceived}${logText}`;
};
return {
message,
pass: matches,
pass,
actual,

@@ -55,4 +72,10 @@ name: matcherName,

log,
timeout: timedOut ? timeout : undefined
timeout: timedOut ? timeout : undefined,
...(printedReceived ? {
printedReceived
} : {}),
...(printedExpected ? {
printedExpected
} : {})
};
}

@@ -43,4 +43,24 @@ "use strict";

} = await query(!!this.isNot, timeout);
const message = pass ? () => (0, _matcherHint.matcherHint)(this, receiver, matcherName, 'locator', undefined, matcherOptions, timedOut ? timeout : undefined) + `Expected: not ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(received)}` + (0, _util.callLogText)(log) : () => (0, _matcherHint.matcherHint)(this, receiver, matcherName, 'locator', undefined, matcherOptions, timedOut ? timeout : undefined) + this.utils.printDiffOrStringify(expected, received, EXPECTED_LABEL, RECEIVED_LABEL, false) + (0, _util.callLogText)(log);
if (pass === !this.isNot) {
return {
name: matcherName,
message: () => '',
pass,
expected
};
}
let printedReceived;
let printedExpected;
let printedDiff;
if (pass) {
printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${this.utils.printReceived(received)}`;
} else {
printedDiff = this.utils.printDiffOrStringify(expected, received, EXPECTED_LABEL, RECEIVED_LABEL, false);
}
const message = () => {
const header = (0, _matcherHint.matcherHint)(this, receiver, matcherName, 'locator', undefined, matcherOptions, timedOut ? timeout : undefined);
const details = printedDiff || `${printedExpected}\n${printedReceived}`;
return `${header}${details}${(0, _util.callLogText)(log)}`;
};
// Passing the actual and expected objects so that a custom reporter

@@ -56,4 +76,13 @@ // could access them, for example in order to display a custom visual diff,

log,
timeout: timedOut ? timeout : undefined
timeout: timedOut ? timeout : undefined,
...(printedReceived ? {
printedReceived
} : {}),
...(printedExpected ? {
printedExpected
} : {}),
...(printedDiff ? {
printedDiff
} : {})
};
}

@@ -141,3 +141,9 @@ "use strict";

message: () => message,
log
log,
// eslint-disable-next-line @typescript-eslint/no-base-to-string
...(this.locator ? {
locator: this.locator.toString()
} : {}),
printedExpected: this.expectedPath,
printedReceived: this.actualPath
};

@@ -144,0 +150,0 @@ return Object.fromEntries(Object.entries(unfiltered).filter(([_, v]) => v !== undefined));

64

lib/matchers/toMatchText.js

@@ -46,2 +46,10 @@ "use strict";

} = await query(!!this.isNot, timeout);
if (pass === !this.isNot) {
return {
name: matcherName,
message: () => '',
pass,
expected
};
}
const stringSubstring = options.matchSubstring ? 'substring' : 'string';

@@ -51,18 +59,37 @@ const receivedString = received || '';

const notFound = received === _matcherHint.kNoElementsFoundError;
const message = () => {
if (pass) {
if (typeof expected === 'string') {
if (notFound) return messagePrefix + `Expected ${stringSubstring}: not ${this.utils.printExpected(expected)}\nReceived: ${received}` + (0, _util.callLogText)(log);
const printedReceived = (0, _expect.printReceivedStringContainExpectedSubstring)(receivedString, receivedString.indexOf(expected), expected.length);
return messagePrefix + `Expected ${stringSubstring}: not ${this.utils.printExpected(expected)}\nReceived string: ${printedReceived}` + (0, _util.callLogText)(log);
let printedReceived;
let printedExpected;
let printedDiff;
if (pass) {
if (typeof expected === 'string') {
if (notFound) {
printedExpected = `Expected ${stringSubstring}: not ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${received}`;
} else {
if (notFound) return messagePrefix + `Expected pattern: not ${this.utils.printExpected(expected)}\nReceived: ${received}` + (0, _util.callLogText)(log);
const printedReceived = (0, _expect.printReceivedStringContainExpectedResult)(receivedString, typeof expected.exec === 'function' ? expected.exec(receivedString) : null);
return messagePrefix + `Expected pattern: not ${this.utils.printExpected(expected)}\nReceived string: ${printedReceived}` + (0, _util.callLogText)(log);
printedExpected = `Expected ${stringSubstring}: not ${this.utils.printExpected(expected)}`;
const formattedReceived = (0, _expect.printReceivedStringContainExpectedSubstring)(receivedString, receivedString.indexOf(expected), expected.length);
printedReceived = `Received string: ${formattedReceived}`;
}
} else {
const labelExpected = `Expected ${typeof expected === 'string' ? stringSubstring : 'pattern'}`;
if (notFound) return messagePrefix + `${labelExpected}: ${this.utils.printExpected(expected)}\nReceived: ${received}` + (0, _util.callLogText)(log);
return messagePrefix + this.utils.printDiffOrStringify(expected, receivedString, labelExpected, 'Received string', false) + (0, _util.callLogText)(log);
if (notFound) {
printedExpected = `Expected pattern: not ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${received}`;
} else {
printedExpected = `Expected pattern: not ${this.utils.printExpected(expected)}`;
const formattedReceived = (0, _expect.printReceivedStringContainExpectedResult)(receivedString, typeof expected.exec === 'function' ? expected.exec(receivedString) : null);
printedReceived = `Received string: ${formattedReceived}`;
}
}
} else {
const labelExpected = `Expected ${typeof expected === 'string' ? stringSubstring : 'pattern'}`;
if (notFound) {
printedExpected = `${labelExpected}: ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${received}`;
} else {
printedDiff = this.utils.printDiffOrStringify(expected, receivedString, labelExpected, 'Received string', false);
}
}
const message = () => {
const resultDetails = printedDiff ? printedDiff : printedExpected + '\n' + printedReceived;
return messagePrefix + resultDetails + (0, _util.callLogText)(log);
};

@@ -76,4 +103,15 @@ return {

log,
timeout: timedOut ? timeout : undefined
timeout: timedOut ? timeout : undefined,
// eslint-disable-next-line @typescript-eslint/no-base-to-string
locator: receiver.toString(),
...(printedReceived ? {
printedReceived
} : {}),
...(printedExpected ? {
printedExpected
} : {}),
...(printedDiff ? {
printedDiff
} : {})
};
}

@@ -372,3 +372,10 @@ "use strict";

message: indent(formattedError.message, initialIndent),
location: formattedError.location
location: formattedError.location,
timeout: error.timeout,
matcherName: error.matcherName,
locator: error.locator,
expected: error.expected,
received: error.received,
log: error.log,
snippet: error.snippet
});

@@ -375,0 +382,0 @@ }

@@ -13,2 +13,3 @@ "use strict";

var _testTracing = require("./testTracing");
var _util2 = require("./util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -210,3 +211,3 @@ /**

if (typeof result.error === 'object' && !((_result$error = result.error) !== null && _result$error !== void 0 && _result$error[stepSymbol])) result.error[stepSymbol] = step;
const error = (0, _util.serializeError)(result.error);
const error = (0, _util2.serializeWorkerError)(result.error);
if (data.boxedStack) error.stack = `${error.message}\n${(0, _utils.stringifyStackFrames)(data.boxedStack).join('\n')}`;

@@ -266,3 +267,3 @@ step.error = error;

if (this.status === 'passed' || this.status === 'skipped') this.status = error instanceof _timeoutManager.TimeoutManagerError ? 'timedOut' : 'failed';
const serialized = (0, _util.serializeError)(error);
const serialized = (0, _util2.serializeWorkerError)(error);
const step = typeof error === 'object' ? error === null || error === void 0 ? void 0 : error[stepSymbol] : undefined;

@@ -269,0 +270,0 @@ if (step && step.boxedStack) serialized.stack = `${error.name}: ${error.message}\n${(0, _utils.stringifyStackFrames)(step.boxedStack).join('\n')}`;

@@ -20,2 +20,3 @@ "use strict";

var _fixtures = require("../common/fixtures");
var _util2 = require("./util");
/**

@@ -120,3 +121,3 @@ * Copyright Microsoft Corporation. All rights reserved.

} catch (e) {
this._fatalErrors.push((0, _util.serializeError)(e));
this._fatalErrors.push((0, _util2.serializeWorkerError)(e));
}

@@ -153,3 +154,3 @@ if (this._fatalErrors.length) {

if (!this._currentTest) {
if (!this._fatalErrors.length) this._fatalErrors.push((0, _util.serializeError)(error));
if (!this._fatalErrors.length) this._fatalErrors.push((0, _util2.serializeWorkerError)(error));
void this._stop();

@@ -218,3 +219,3 @@ return;

// but not in the runner, let's do a fatal error.
this._fatalErrors.push((0, _util.serializeError)(e));
this._fatalErrors.push((0, _util2.serializeWorkerError)(e));
void this._stop();

@@ -221,0 +222,0 @@ } finally {

{
"name": "playwright",
"version": "1.49.0-alpha-2024-10-21",
"version": "1.49.0-alpha-2024-10-22",
"description": "A high-level API to automate web browsers",

@@ -59,3 +59,3 @@ "repository": {

"dependencies": {
"playwright-core": "1.49.0-alpha-2024-10-21"
"playwright-core": "1.49.0-alpha-2024-10-22"
},

@@ -62,0 +62,0 @@ "optionalDependencies": {

@@ -558,2 +558,7 @@ // This file is generated by /utils/generate_types/index.js

/**
* Expected value formatted as a human-readable string.
*/
expected?: string;
/**
* Error location in the source code.

@@ -564,2 +569,17 @@ */

/**
* Receiver's locator.
*/
locator?: string;
/**
* Call log.
*/
log?: Array<string>;
/**
* Expect matcher name.
*/
matcherName?: string;
/**
* Error message. Set when [Error] (or its subclass) has been thrown.

@@ -570,2 +590,7 @@ */

/**
* Received value formatted as a human-readable string.
*/
received?: string;
/**
* Source code snippet with highlighted error.

@@ -581,2 +606,7 @@ */

/**
* Timeout in milliseconds, if the error was caused by a timeout.
*/
timeout?: number;
/**
* The value that was thrown. Set when anything except the [Error] (or its subclass) has been thrown.

@@ -583,0 +613,0 @@ */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc