playwright
Advanced tools
Comparing version 1.50.0-alpha-2024-12-17 to 1.50.0-alpha-2024-12-18
@@ -60,3 +60,5 @@ "use strict"; | ||
test.setTimeout = (0, _transform.wrapFunctionWithLocation)(this._setTimeout.bind(this)); | ||
test.step = this._step.bind(this); | ||
test.step = this._step.bind(this, 'pass'); | ||
test.step.fail = this._step.bind(this, 'fail'); | ||
test.step.fixme = this._step.bind(this, 'fixme'); | ||
test.use = (0, _transform.wrapFunctionWithLocation)(this._use.bind(this)); | ||
@@ -227,5 +229,6 @@ test.extend = (0, _transform.wrapFunctionWithLocation)(this._extend.bind(this)); | ||
} | ||
async _step(title, body, options = {}) { | ||
async _step(expectation, title, body, options = {}) { | ||
const testInfo = (0, _globals.currentTestInfo)(); | ||
if (!testInfo) throw new Error(`test.step() can only be called from a test`); | ||
if (expectation === 'fixme') return undefined; | ||
const step = testInfo._addStep({ | ||
@@ -238,8 +241,12 @@ category: 'test.step', | ||
return await _utils.zones.run('stepZone', step, async () => { | ||
var _result; | ||
let result; | ||
let error; | ||
try { | ||
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) { | ||
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.`); | ||
step.complete({ | ||
@@ -250,2 +257,19 @@ 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; | ||
}); | ||
@@ -252,0 +276,0 @@ } |
{ | ||
"name": "playwright", | ||
"version": "1.50.0-alpha-2024-12-17", | ||
"version": "1.50.0-alpha-2024-12-18", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -59,3 +59,3 @@ "repository": { | ||
"dependencies": { | ||
"playwright-core": "1.50.0-alpha-2024-12-17" | ||
"playwright-core": "1.50.0-alpha-2024-12-18" | ||
}, | ||
@@ -62,0 +62,0 @@ "optionalDependencies": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3164807
36077
+ Addedplaywright-core@1.50.0-alpha-2024-12-18(transitive)
- Removedplaywright-core@1.50.0-alpha-2024-12-17(transitive)