effect-playwright
    Preparing search index...

    Interface Tracing

    0.5.0

    interface Tracing {
        start: (
            options?: {
                live?: boolean;
                name?: string;
                screenshots?: boolean;
                snapshots?: boolean | { aria?: boolean; dom?: boolean; screen?: boolean };
                sources?: boolean;
                title?: string;
            },
        ) => Effect<void, PlaywrightError>;
        startChunk: (
            options?: { name?: string; title?: string },
        ) => Effect<void, PlaywrightError>;
        startChunkScoped: (
            options?: { name?: string; title?: string },
            stopOptions?: { path?: string },
        ) => Effect<void, PlaywrightError, Scope>;
        startHar: (options: string) => Effect<void, PlaywrightError>;
        startScoped: (
            options?: {
                live?: boolean;
                name?: string;
                screenshots?: boolean;
                snapshots?: boolean | { aria?: boolean; dom?: boolean; screen?: boolean };
                sources?: boolean;
                title?: string;
            },
            stopOptions?: { path?: string },
        ) => Effect<void, PlaywrightError, Scope>;
        stop: (options?: { path?: string }) => Effect<void, PlaywrightError>;
        stopChunk: (options?: { path?: string }) => Effect<void, PlaywrightError>;
        stopHar: Effect<void, PlaywrightError>;
    }
    Index
    start: (
        options?: {
            live?: boolean;
            name?: string;
            screenshots?: boolean;
            snapshots?: boolean | { aria?: boolean; dom?: boolean; screen?: boolean };
            sources?: boolean;
            title?: string;
        },
    ) => Effect<void, PlaywrightError>

    Starts tracing.

    0.5.0

    startChunk: (
        options?: { name?: string; title?: string },
    ) => Effect<void, PlaywrightError>

    Starts a new tracing chunk.

    0.5.0

    startChunkScoped: (
        options?: { name?: string; title?: string },
        stopOptions?: { path?: string },
    ) => Effect<void, PlaywrightError, Scope>

    Starts a new tracing chunk and stops it when the current Scope closes.

    Tracing must already be started. Pass stopOptions.path to save the chunk; a failure while stopping is logged instead of failing the scope.

    Type Declaration

      • (
            options?: { name?: string; title?: string },
            stopOptions?: { path?: string },
        ): Effect<void, PlaywrightError, Scope>
      • Parameters

        • Optionaloptions: { name?: string; title?: string }

          Options passed to Tracing.startChunk.

          • Optionalname?: string

            If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the tracesDir directory specified in browserType.launch([options]). To specify the final trace zip file name, you need to pass path option to tracing.stopChunk([options]) instead.

          • Optionaltitle?: string

            Trace name to be shown in the Trace Viewer.

        • OptionalstopOptions: { path?: string }

          Options passed to Tracing.stopChunk when the scope closes.

        Returns Effect<void, PlaywrightError, Scope>

    0.9.0

    startHar: (options: string) => Effect<void, PlaywrightError>

    Starts HAR recording.

    0.5.0

    startScoped: (
        options?: {
            live?: boolean;
            name?: string;
            screenshots?: boolean;
            snapshots?: boolean | { aria?: boolean; dom?: boolean; screen?: boolean };
            sources?: boolean;
            title?: string;
        },
        stopOptions?: { path?: string },
    ) => Effect<void, PlaywrightError, Scope>

    Starts tracing and stops it when the current Scope closes.

    When to use

    Use instead of pairing Tracing.start with Tracing.stop, so the trace is stopped even when the workflow fails or is interrupted.

    Gotchas

    Pass stopOptions.path to save the trace; without it Playwright discards the recording. A failure while stopping is logged instead of failing the scope.

    Type Declaration

      • (
            options?: {
                live?: boolean;
                name?: string;
                screenshots?: boolean;
                snapshots?: boolean | { aria?: boolean; dom?: boolean; screen?: boolean };
                sources?: boolean;
                title?: string;
            },
            stopOptions?: { path?: string },
        ): Effect<void, PlaywrightError, Scope>
      • Parameters

        • Optionaloptions: {
              live?: boolean;
              name?: string;
              screenshots?: boolean;
              snapshots?: boolean | { aria?: boolean; dom?: boolean; screen?: boolean };
              sources?: boolean;
              title?: string;
          }

          Options passed to Tracing.start.

          • Optionallive?: boolean

            When enabled, the trace is written to an unarchived file that is updated in real time as actions occur, instead of caching changes and archiving them into a zip file at the end. This is useful for live trace viewing during test execution.

          • Optionalname?: string

            If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the tracesDir directory specified in browserType.launch([options]). To specify the final trace zip file name, you need to pass path option to tracing.stop([options]) instead.

          • Optionalscreenshots?: boolean

            Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.

          • Optionalsnapshots?: boolean | { aria?: boolean; dom?: boolean; screen?: boolean }

            Which snapshots to capture on every action. Passing true is a shortcut for { dom: true }.

          • Optionalsources?: boolean

            Whether to include source files for trace actions.

          • Optionaltitle?: string

            Trace name to be shown in the Trace Viewer.

        • OptionalstopOptions: { path?: string }

          Options passed to Tracing.stop when the scope closes.

          • Optionalpath?: string

            Export trace into the file with the given path.

        Returns Effect<void, PlaywrightError, Scope>

    import { Effect } from "effect";
    import { Playwright } from "effect-playwright";
    import { chromium } from "playwright-core";

    const program = Effect.gen(function* () {
    const playwright = yield* Playwright.Playwright;
    const browser = yield* playwright.launchScoped(chromium);
    const context = yield* browser.newContext();
    yield* context.tracing.startScoped(
    { screenshots: true, snapshots: true },
    { path: "trace.zip" },
    );
    const page = yield* context.newPage;
    yield* page.goto("https://example.com");
    }).pipe(Effect.scoped, Effect.provide(Playwright.layer));

    0.9.0

    stop: (options?: { path?: string }) => Effect<void, PlaywrightError>

    Stops tracing.

    0.5.0

    stopChunk: (options?: { path?: string }) => Effect<void, PlaywrightError>

    Stops a tracing chunk.

    0.5.0

    stopHar: Effect<void, PlaywrightError>

    Stops HAR recording.

    0.5.0