playwright
Advanced tools
Comparing version
@@ -47,3 +47,2 @@ "use strict"; | ||
require('node:module').register(_url.default.pathToFileURL(require.resolve('../transform/esmLoader')), { | ||
parentURL: _url.default.pathToFileURL(__filename), | ||
data: { | ||
@@ -50,0 +49,0 @@ port: port2 |
@@ -61,4 +61,3 @@ "use strict"; | ||
test.step = this._step.bind(this, 'pass'); | ||
test.step.fail = this._step.bind(this, 'fail'); | ||
test.step.fixme = this._step.bind(this, 'fixme'); | ||
test.step.skip = this._step.bind(this, 'skip'); | ||
test.use = (0, _transform.wrapFunctionWithLocation)(this._use.bind(this)); | ||
@@ -232,3 +231,12 @@ test.extend = (0, _transform.wrapFunctionWithLocation)(this._extend.bind(this)); | ||
if (!testInfo) throw new Error(`test.step() can only be called from a test`); | ||
if (expectation === 'fixme') return undefined; | ||
if (expectation === 'skip') { | ||
const step = testInfo._addStep({ | ||
category: 'test.step.skip', | ||
title, | ||
location: options.location, | ||
box: options.box | ||
}); | ||
step.complete({}); | ||
return undefined; | ||
} | ||
const step = testInfo._addStep({ | ||
@@ -241,12 +249,8 @@ category: 'test.step', | ||
return await _utils.zones.run('stepZone', step, async () => { | ||
var _result; | ||
let result; | ||
let error; | ||
try { | ||
result = await (0, _utils.raceAgainstDeadline)(async () => body(), options.timeout ? (0, _utils.monotonicTime)() + options.timeout : 0); | ||
} catch (e) { | ||
error = e; | ||
} | ||
if ((_result = result) !== null && _result !== void 0 && _result.timedOut) { | ||
const error = new _playwrightCore.errors.TimeoutError(`Step timeout ${options.timeout}ms exceeded.`); | ||
const result = await (0, _utils.raceAgainstDeadline)(async () => body(), options.timeout ? (0, _utils.monotonicTime)() + options.timeout : 0); | ||
if (result.timedOut) throw new _playwrightCore.errors.TimeoutError(`Step timeout ${options.timeout}ms exceeded.`); | ||
step.complete({}); | ||
return result.result; | ||
} catch (error) { | ||
step.complete({ | ||
@@ -257,19 +261,2 @@ error | ||
} | ||
const expectedToFail = expectation === 'fail'; | ||
if (error) { | ||
step.complete({ | ||
error | ||
}); | ||
if (expectedToFail) return undefined; | ||
throw error; | ||
} | ||
if (expectedToFail) { | ||
error = new Error(`Step is expected to fail, but passed`); | ||
step.complete({ | ||
error | ||
}); | ||
throw error; | ||
} | ||
step.complete({}); | ||
return result.result; | ||
}); | ||
@@ -276,0 +263,0 @@ } |
@@ -444,8 +444,8 @@ "use strict"; | ||
if (!testInfo || data.apiName.includes('setTestIdAttribute') || data.apiName === 'tracing.groupEnd') return; | ||
const expectZone = _utils.zones.zoneData('expectZone'); | ||
if (expectZone) { | ||
const zone = _utils.zones.zoneData('stepZone'); | ||
if (zone && zone.category === 'expect') { | ||
// Display the internal locator._expect call under the name of the enclosing expect call, | ||
// and connect it to the existing expect step. | ||
data.apiName = expectZone.title; | ||
data.stepId = expectZone.stepId; | ||
data.apiName = zone.title; | ||
data.stepId = zone.stepId; | ||
return; | ||
@@ -452,0 +452,0 @@ } |
@@ -238,5 +238,6 @@ "use strict"; | ||
// 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), | ||
@@ -268,8 +269,3 @@ params: args[0] ? { | ||
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); | ||
@@ -276,0 +272,0 @@ finalizer(); |
@@ -215,28 +215,14 @@ "use strict"; | ||
} | ||
function toHaveAccessibleName(locator, expected, options = {}) { | ||
if (Array.isArray(expected)) { | ||
return _toEqual.toEqual.call(this, 'toHaveAccessibleName', 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.name.array', { | ||
expectedText, | ||
isNot, | ||
timeout | ||
}); | ||
}, expected, options); | ||
} else { | ||
return _toMatchText.toMatchText.call(this, 'toHaveAccessibleName', 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.name', { | ||
expectedText, | ||
isNot, | ||
timeout | ||
}); | ||
}, expected, options); | ||
} | ||
function toHaveAccessibleName(locator, expected, options) { | ||
return _toMatchText.toMatchText.call(this, 'toHaveAccessibleName', 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.name', { | ||
expectedText, | ||
isNot, | ||
timeout | ||
}); | ||
}, expected, options); | ||
} | ||
@@ -243,0 +229,0 @@ function toHaveAccessibleErrorMessage(locator, expected, options) { |
@@ -503,2 +503,3 @@ "use strict"; | ||
} = dedupedStep; | ||
const skipped = dedupedStep.step.category === 'test.step.skip'; | ||
const testStep = { | ||
@@ -516,3 +517,4 @@ title: step.title, | ||
error: (_step$error = step.error) === null || _step$error === void 0 ? void 0 : _step$error.message, | ||
count | ||
count, | ||
skipped | ||
}; | ||
@@ -519,0 +521,0 @@ if (step.location) this._stepsInFile.set(step.location.file, testStep); |
@@ -149,4 +149,4 @@ "use strict"; | ||
for (const a of attachments) { | ||
var _this$_expectStepId, _this$_parentStep; | ||
this._attach(a, (_this$_expectStepId = this._expectStepId()) !== null && _this$_expectStepId !== void 0 ? _this$_expectStepId : (_this$_parentStep = this._parentStep()) === null || _this$_parentStep === void 0 ? void 0 : _this$_parentStep.stepId); | ||
var _this$_parentStep; | ||
this._attach(a, (_this$_parentStep = this._parentStep()) === null || _this$_parentStep === void 0 ? void 0 : _this$_parentStep.stepId); | ||
} | ||
@@ -188,6 +188,2 @@ return this.attachments.length; | ||
} | ||
_expectStepId() { | ||
var _zones$zoneData2; | ||
return (_zones$zoneData2 = _utils.zones.zoneData('expectZone')) === null || _zones$zoneData2 === void 0 ? void 0 : _zones$zoneData2.stepId; | ||
} | ||
_addStep(data, parentStep) { | ||
@@ -194,0 +190,0 @@ var _parentStep, _parentStep2; |
{ | ||
"name": "playwright", | ||
"version": "1.50.0-alpha-1736502759000", | ||
"version": "1.50.0-alpha-1737068696000", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -59,3 +59,3 @@ "repository": { | ||
"dependencies": { | ||
"playwright-core": "1.50.0-alpha-1736502759000" | ||
"playwright-core": "1.50.0-alpha-1737068696000" | ||
}, | ||
@@ -62,0 +62,0 @@ "optionalDependencies": { |
# 🎭 Playwright | ||
[](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[](https://webkit.org/)<!-- GEN:stop --> [](https://aka.ms/playwright/discord) | ||
[](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[](https://webkit.org/)<!-- GEN:stop --> [](https://aka.ms/playwright/discord) | ||
@@ -13,3 +13,3 @@ ## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright) | ||
| WebKit <!-- GEN:webkit-version -->18.2<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
| Firefox <!-- GEN:firefox-version -->132.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
| Firefox <!-- GEN:firefox-version -->134.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
@@ -16,0 +16,0 @@ Headless execution is supported for all browsers on all platforms. Check out [system requirements](https://playwright.dev/docs/intro#system-requirements) for details. |
Sorry, the diff of this file is too big to display
3173050
-0.06%36242
-0.15%+ Added
- Removed