Skip to content

fix(tracing): Adjust trace-artifact granularity and grouping in @wdio/devtools-service#234

Open
Winify wants to merge 2 commits into
webdriverio:mainfrom
Winify:fix/tracing-granularity
Open

fix(tracing): Adjust trace-artifact granularity and grouping in @wdio/devtools-service#234
Winify wants to merge 2 commits into
webdriverio:mainfrom
Winify:fix/tracing-granularity

Conversation

@Winify

@Winify Winify commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What & why

Three tracing fixes/features for @wdio/devtools-service:

Bug fix — lastSelector bleed-through across tests. Element-scoped commands (click, setValue, etc.) in test B could silently inherit the selector from test A's last $() / findElement call. Fixed by resetting the selector cache in beforeTest() via SessionCapturer.resetLastSelector().

Feature — traceGranularity: 'spec'. Each spec file now produces its own trace artifact (zip or ndjson-directory) instead of one monolithic trace per worker session. Enabled via traceGranularity: 'spec' in the service options. Default remains 'session'.

Feature — it() / Scenario() grouping in traces. When test hooks are available, each test becomes a Tracing.tracingGroup span in the trace NDJSON. Child actions carry parentId pointing to the group so timeline viewers render tests as labelled spans wrapping their commands.

// wdio.conf.js
services: [['devtools', {
    mode: 'trace',
    traceFormat: 'zip',
    traceGranularity: 'spec'     // one trace per spec file
}]]

How

  • testUid (deterministic hash of specFile + testTitle) is tagged on every captured command via SessionCapturer.afterCommand().
  • buildActionEvents() in core/trace-exporter.ts detects testUid changes in the command stream and emits tracingGroup open/close pairs.
  • beforeTest() tracks spec-file boundaries via index ranges (SpecRange). #flushSpecTrace() slices the accumulated arrays and writes a standalone trace artifact per spec. Mid-run flushes are fire-and-forget with .catch() error logging.
  • Spec-scoped test metadata is derived from a single #testMetadata map filtered by specFile — no dual-source-of-truth risk.
  • Trace filenames include an 8-char base36 hash of the full spec path, so two specs with the same basename in different directories don't collide.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Polish (an improvement to an existing feature)
  • Breaking change (existing behavior changes for users)
  • Documentation
  • Internal (build, CI, dependencies, tooling)

Packages touched

  • shared (types and contracts)
  • core (framework-agnostic capture/reporting)
  • service (WebdriverIO adapter)
  • nightwatch-devtools (Nightwatch adapter)
  • selenium-devtools (Selenium adapter)
  • backend (server)
  • app (UI)
  • script (page-injected runtime)

Notes for reviewers

Screenshots / recordings

Winify added 2 commits June 18, 2026 15:51
- Add @changesets/cli for per-package versioning
- Replace workflow_dispatch release.yml with changesets/action (Version Packages PR on push to main → publish on merge)
- releaseType input is replaced by changeset files: pnpm changeset picks which packages + what bump
- Only packages with pending changesets get published
…/devtools-service

- Correct `lastSelector` when different tests bleed through it
- Introduce `spec-level` tracing (both artifact and ndjson-directory)
- Intorduce it() grouping in traces
@Winify Winify force-pushed the fix/tracing-granularity branch from b4b8563 to 9d397c7 Compare June 18, 2026 14:37
@Winify Winify requested a review from vishnuv688 June 18, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant