diff --git a/docs/api.md b/docs/api.md index b01dd5e7064..845fadc850c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -180,7 +180,7 @@ - [class: Touchscreen](#class-touchscreen) * [touchscreen.tap(x, y)](#touchscreentapx-y) - [class: Tracing](#class-tracing) - * [tracing.start(options)](#tracingstartoptions) + * [tracing.start([options])](#tracingstartoptions) * [tracing.stop()](#tracingstop) - [class: Dialog](#class-dialog) * [dialog.accept([promptText])](#dialogacceptprompttext) @@ -2319,7 +2319,7 @@ await page.goto('https://www.google.com'); await page.tracing.stop(); ``` -#### tracing.start(options) +#### tracing.start([options]) - `options` <[Object]> - `path` <[string]> A path to write the trace file to. - `screenshots` <[boolean]> captures screenshots in the trace. diff --git a/lib/Tracing.js b/lib/Tracing.js index 37fc8410b6e..b76674fcd3e 100644 --- a/lib/Tracing.js +++ b/lib/Tracing.js @@ -31,9 +31,9 @@ class Tracing { } /** - * @param {!{path: string, screenshots?: boolean, categories?: !Array}} options + * @param {!{path?: string, screenshots?: boolean, categories?: !Array}} options */ - async start(options) { + async start(options = {}) { assert(!this._recording, 'Cannot start recording trace while already recording trace.'); const defaultCategories = [ @@ -75,7 +75,7 @@ class Tracing { /** * @param {string} handle - * @param {string} path + * @param {?string} path */ async _readStream(handle, path) { let eof = false; diff --git a/test/tracing.spec.js b/test/tracing.spec.js index f89e3b8d5ce..ffa054388d3 100644 --- a/test/tracing.spec.js +++ b/test/tracing.spec.js @@ -66,6 +66,12 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p const buf = fs.readFileSync(outputFile); expect(trace.toString()).toEqual(buf.toString()); }); + it('should work without options', async({page, server, outputFile}) => { + await page.tracing.start(); + await page.goto(server.PREFIX + '/grid.html'); + const trace = await page.tracing.stop(); + expect(trace).toBeTruthy(); + }); it('should return null in case of Buffer error', async({page, server}) => { await page.tracing.start({screenshots: true}); await page.goto(server.PREFIX + '/grid.html');