Skip to content

Expose getRunner() function#397

Merged
hawkeyexl merged 12 commits intomainfrom
dynamic-analyzer
Dec 1, 2025
Merged

Expose getRunner() function#397
hawkeyexl merged 12 commits intomainfrom
dynamic-analyzer

Conversation

@hawkeyexl
Copy link
Contributor

@hawkeyexl hawkeyexl commented Nov 29, 2025

Introduce the getRunner() function for creating a Chrome WebDriver instance with an Appium server, enhancing automation capabilities. Additionally, establish unit tests to ensure functionality and reliability.

Summary by CodeRabbit

  • New Features

    • Added a public API to create pre-configured Chrome WebDriver instances with integrated Appium startup, automatic environment/server initialization, window sizing, and cleanup utilities.
  • Tests

    • Added comprehensive tests covering many configurations and behaviors (headless/non-headless, varied sizes, custom options, cleanup idempotence, sequential runs, navigation, and platform interactions).
  • Chores

    • Updated minor dependency versions for underlying tooling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 29, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a new public API getRunner(options) that starts an Appium server, creates a Chrome WebDriver session with resolved capabilities and window sizing, exposes runStep and cleanup, adds comprehensive tests for getRunner, and bumps a few dependencies.

Changes

Cohort / File(s) Change Summary
Public API Export
src/index.js
Exposes getRunner from the tests module (exports.getRunner = getRunner).
Runner Implementation
src/tests.js
Adds getRunner(options = {}): starts/stops Appium, validates Chrome availability, resolves capabilities, attempts driverStart (with retry switching to headless), applies window sizing, returns { runner, appium, runStep, cleanup } with idempotent cleanup.
Test Coverage
test/core.test.js
Adds extensive tests for getRunner() covering default/headless/non-headless modes, various window sizes, returned API shape and methods, navigation/title/element checks, cleanup idempotency, and sequential runner scenarios.
Dependencies
package.json
Bumps dependency versions: @apidevtools/json-schema-ref-parser → ^15.1.3, posthog-node → ^5.14.1, webdriverio → ^9.21.0.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Test / Caller
    participant Appium as Appium (process)
    participant Caps as Capability Resolver
    participant Driver as Chrome WebDriver
    participant Cleanup as Cleanup Routine

    Caller->>Appium: spawn/start Appium (env/options)
    Note right of Appium: process startup & readiness probe
    Appium-->>Caller: ready

    Caller->>Caps: resolve Chrome capabilities (platform mapping + options)
    Caps-->>Caller: capabilities

    Caller->>Driver: init WebDriver with capabilities (driverStart)
    alt driverStart fails
        Caller->>Driver: retry driverStart with headless capability
    end
    Driver-->>Caller: runner instance

    Caller->>Driver: set window size (width × height)
    Driver-->>Caller: window size applied

    Caller-->>Caller: return { runner, appium, runStep, cleanup }

    alt caller finishes
        Caller->>Cleanup: call cleanup()
        Cleanup->>Driver: deleteSession (if open)
        Cleanup->>Appium: stop Appium process
        Cleanup-->>Caller: cleanup complete
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Files meriting extra attention:
    • src/tests.js: Appium lifecycle, readiness/retry logic, headless fallback, capability merging, and cleanup idempotency.
    • test/core.test.js: Large, timing-sensitive test matrix — watch for environment assumptions and flakiness.
    • src/index.js: simple export addition — verify no export collisions.
    • package.json: dependency bumps — confirm compatibility with CI/runtime.

Poem

🐇 I spun Appium beneath a silver light,

Chrome stretched, then hopped from page to page,
runStep hummed a tiny tune of flight,
windows sized snug in every stage,
cleanup tucked them—all snug and bright.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and concisely summarizes the main change: exposing the getRunner() function as a new public API export.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dynamic-analyzer

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fed00fe and 8e1126f.

📒 Files selected for processing (2)
  • src/tests.js (8 hunks)
  • test/core.test.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
test/**/*.test.js

📄 CodeRabbit inference engine (AGENTS.md)

Tests must use mocha with this.timeout(0) for indefinite timeout to avoid test failures on long-running operations

Files:

  • test/core.test.js
test/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

Use fs.writeFileSync() + fs.unlinkSync() in try/finally blocks for temporary test files to ensure cleanup

Files:

  • test/core.test.js
src/tests.js

📄 CodeRabbit inference engine (AGENTS.md)

src/tests.js: Register new step types in src/tests.js: add action to driverActions array if requires browser, add case in runStep() switch statement
Configure Appium drivers (chromium, gecko, safari on macOS) with default 10-minute timeout via newCommandTimeout: 600
Core test runner src/tests.js orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Files:

  • src/tests.js
src/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.js: Use log(config, level, message) for logging where level is 'debug'|'info'|'warning'|'error', passing config object as first parameter
Use getAvailableApps() to detect installed browsers rather than hardcoding browser paths, accounting for platform-specific locations

Files:

  • src/tests.js
🧠 Learnings (13)
📓 Common learnings
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/index.js : Entry point `src/index.js` must expose `runTests()` function as the primary API for test execution

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/*.js : Create new step type handlers in `src/tests/[actionName].js` exporting async functions that validate schema, resolve to object, set defaults, and return `{ status: 'PASS'|'FAIL'|'WARNING', description: string, outputs: {} }`

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Tests follow nested hierarchy: spec (file) → test → context (browser/platform combo) → step (action), with contexts running serially and skipping if unsupported

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Always handle driver cleanup in try/finally blocks to ensure WebDriver sessions are properly terminated

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to test/**/*.test.js : Tests must use mocha with `this.timeout(0)` for indefinite timeout to avoid test failures on long-running operations

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to test/**/*.js : Use `fs.writeFileSync()` + `fs.unlinkSync()` in try/finally blocks for temporary test files to ensure cleanup

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Each step type has dedicated handler module in `src/tests/` (e.g., `httpRequest.js`, `runShell.js`) implementing specific action logic

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Set step variables via `step.variables = { MY_VAR: '$$response.body.token' }` to store runtime values as environment variables for subsequent steps

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed

Applied to files:

  • src/tests.js
🧬 Code graph analysis (1)
test/core.test.js (1)
src/tests.js (6)
  • cleanup (1050-1061)
  • width (976-976)
  • height (977-977)
  • runner (1022-1022)
  • appium (381-381)
  • appium (1000-1004)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test (ubuntu-latest, 20)
  • GitHub Check: test (macos-latest, 24)
  • GitHub Check: test (macos-latest, 22)
  • GitHub Check: test (windows-latest, 22)
  • GitHub Check: test (ubuntu-latest, 24)
  • GitHub Check: test (windows-latest, 24)
  • GitHub Check: test (macos-latest, 20)
  • GitHub Check: test (ubuntu-latest, 22)
  • GitHub Check: test (windows-latest, 20)
🔇 Additional comments (7)
test/core.test.js (2)

419-449: Excellent test structure and timeout configuration.

The test suite correctly uses this.timeout(0) for indefinite timeout per coding guidelines, and the first test properly validates the structure of the returned object from getRunner(). The try/finally pattern ensures cleanup even on test failure.

Based on coding guidelines.


482-825: Comprehensive test coverage for the getRunner API.

The test suite thoroughly covers the getRunner() API including edge cases, error handling, cleanup behavior, and window sizing with appropriate tolerance for browser variance. The consistent use of try/finally blocks ensures proper resource cleanup across all test scenarios.

src/tests.js (5)

32-32: LGTM: Public API export.

Correctly exposes the new getRunner() function as part of the module's public API surface, enabling external libraries to create browser automation runners programmatically.


262-266: Improved error handling with optional chaining.

The addition of optional chaining (?.) for error response properties prevents potential crashes when the error object doesn't have the expected structure, making the API error handling more defensive and robust.

Also applies to: 283-287, 305-308


805-810: Good defensive coding with parameter defaults.

Adding default empty objects for config, context, and metaValues parameters, along with optional chaining for config?.recording, makes the runStep() function more resilient to missing arguments and safer for external callers.

Also applies to: 888-888


948-972: Well-documented public API with accurate JSDoc.

The JSDoc correctly documents the return structure and includes a practical example. The documentation properly names the returned WebDriver instance as runner (matching the implementation) and clearly explains the purpose of each returned field.


973-1064: Solid implementation of getRunner with proper error handling.

The getRunner() implementation correctly:

  • Validates Chrome availability before attempting to start
  • Starts Appium and waits for readiness
  • Includes fallback to headless mode if initial driver start fails
  • Provides a cleanup function that safely handles both driver and Appium termination
  • Returns all necessary components (runner, appium, cleanup, runStep) for external library integration

The retry logic for headless mode (lines 1026-1039) is particularly valuable for CI environments where non-headless mode may not be supported.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/index.js (1)

5-9: getRunner re-export from index.js is wired correctly

Importing getRunner from ./tests and exporting it alongside runTests cleanly exposes the new API while keeping runTests as the primary entry point.

Optionally, consider adding a small test that imports { getRunner } from "../src" to exercise the public re-export, since current tests pull it from "../src/tests".

test/core.test.js (1)

419-830: Strong getRunner coverage; align timeouts and cleanup patterns, and consider testing the public export

The new describe("getRunner() function", ...) block does a thorough job of exercising the new API: default vs. non‑headless, custom and default dimensions, config handling, cleanup behavior (including idempotence and already‑closed sessions), sequential runners, basic navigation, and the presence/type of runStep. That’s excellent coverage.

A few targeted tweaks will make this suite more robust and better aligned with project conventions:

  1. Timeout policy
  • Here you use this.timeout(60000), whereas other suites in this file follow the guideline of this.timeout(0) for long‑running/browser tests.
  • Given Appium + browser startup can easily exceed 60s on slower CI (especially Windows), strongly consider switching this to this.timeout(0) to avoid flakiness, consistent with the documented test/**/*.test.js guideline. As per coding guidelines, tests should use an indefinite timeout.
  1. Ensure cleanup is always called via try/finally

Most tests correctly pattern:

let cleanup;
try {
  const result = await getRunner();
  cleanup = result.cleanup;
  // ...assertions...
} finally {
  if (cleanup) await cleanup();
}

But a few use getRunner without guarding cleanup in a finally block (e.g., “cleanup function should properly close runner session”, “cleanup function should terminate Appium process”, “cleanup should be idempotent”, “should handle multiple sequential runners”, “cleanup should handle errors gracefully when session already closed”). If an assertion or navigation fails before cleanup() is reached, Appium may be left running and hang the test process.

I’d standardize all getRunner usages in this describe to the same try/finally pattern used in other tests so driver/Appium cleanup is guaranteed even on failure.

  1. Optionally test the public export

Right now you import getRunner from "../src/tests". Since src/index.js now re‑exports getRunner, consider either:

  • Importing from "../src" in this suite, or
  • Adding a tiny separate test that asserts require("../src").getRunner is a function.

That will help catch accidental regressions in the public API surface.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 769cb83 and 63ac902.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • src/index.js (1 hunks)
  • src/tests.js (4 hunks)
  • test/core.test.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
test/**/*.test.js

📄 CodeRabbit inference engine (AGENTS.md)

Tests must use mocha with this.timeout(0) for indefinite timeout to avoid test failures on long-running operations

Files:

  • test/core.test.js
test/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

Use fs.writeFileSync() + fs.unlinkSync() in try/finally blocks for temporary test files to ensure cleanup

Files:

  • test/core.test.js
src/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.js: Use log(config, level, message) for logging where level is 'debug'|'info'|'warning'|'error', passing config object as first parameter
Use getAvailableApps() to detect installed browsers rather than hardcoding browser paths, accounting for platform-specific locations

Files:

  • src/index.js
  • src/tests.js
src/index.js

📄 CodeRabbit inference engine (AGENTS.md)

Entry point src/index.js must expose runTests() function as the primary API for test execution

Files:

  • src/index.js
src/tests.js

📄 CodeRabbit inference engine (AGENTS.md)

src/tests.js: Register new step types in src/tests.js: add action to driverActions array if requires browser, add case in runStep() switch statement
Configure Appium drivers (chromium, gecko, safari on macOS) with default 10-minute timeout via newCommandTimeout: 600
Core test runner src/tests.js orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Files:

  • src/tests.js
🧠 Learnings (17)
📓 Common learnings
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/index.js : Entry point `src/index.js` must expose `runTests()` function as the primary API for test execution
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Always handle driver cleanup in try/finally blocks to ensure WebDriver sessions are properly terminated
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Applied to files:

  • test/core.test.js
  • src/index.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/index.js : Entry point `src/index.js` must expose `runTests()` function as the primary API for test execution

Applied to files:

  • test/core.test.js
  • src/index.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Tests follow nested hierarchy: spec (file) → test → context (browser/platform combo) → step (action), with contexts running serially and skipping if unsupported

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/*.js : Create new step type handlers in `src/tests/[actionName].js` exporting async functions that validate schema, resolve to object, set defaults, and return `{ status: 'PASS'|'FAIL'|'WARNING', description: string, outputs: {} }`

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Always handle driver cleanup in try/finally blocks to ensure WebDriver sessions are properly terminated

Applied to files:

  • test/core.test.js
  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Use `setViewportSize()` to set inner viewport dimensions, which calculates delta from window size rather than setting window size directly

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Each step type has dedicated handler module in `src/tests/` (e.g., `httpRequest.js`, `runShell.js`) implementing specific action logic

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to test/**/*.test.js : Tests must use mocha with `this.timeout(0)` for indefinite timeout to avoid test failures on long-running operations

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Set step variables via `step.variables = { MY_VAR: '$$response.body.token' }` to store runtime values as environment variables for subsequent steps

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Input resolution via `doc-detective-resolver` detects tests from docs/specs and resolves to executable format as first step in test execution flow

Applied to files:

  • src/index.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Run local test suite with `npm test` (mocha), use `node dev` for development/manual testing, run `npm run depcheck` to check unused dependencies

Applied to files:

  • src/index.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Test & Publish workflow runs cross-platform tests (Ubuntu/Windows/macOS × Node 18/20/22/24) before publishing; triggers downstream `doc-detective` update via repository dispatch

Applied to files:

  • src/index.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/**/*.js : Use `getAvailableApps()` to detect installed browsers rather than hardcoding browser paths, accounting for platform-specific locations

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed

Applied to files:

  • src/tests.js
🧬 Code graph analysis (1)
test/core.test.js (1)
src/tests.js (6)
  • cleanup (1039-1054)
  • width (972-972)
  • height (973-973)
  • runner (1018-1018)
  • appium (373-373)
  • appium (996-1000)
🔇 Additional comments (1)
src/tests.js (1)

795-803: runStep defaults and recording guard improve robustness

Defaulting config, context, and metaValues plus switching to config?.recording makes runStep safer to call from external contexts (like the new getRunner API) without requiring callers to always construct full objects. This helps avoid runtime errors when config or metaValues are omitted, while preserving existing behavior.

No changes requested here.

Also applies to: 881-886

@promptless
Copy link

promptless bot commented Nov 29, 2025

📝 Documentation updates detected!

New suggestion: Document getRunner() programmatic API

- Use getEnvironment() to build an environment object and include it in config and runnerDetails instead of recreating platform manually
- Update JSDoc and example to refer to "runner" (WebDriver) instead of "driver"
- Clarify appium termination guidance and add runStep to the documented returned properties
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/tests.js (2)

795-906: runStep defaults and recording hook look good; consider guarding driver access

The new defaults for config, context, and metaValues make runStep safer to call from external code, and the recording block that instantiates the cursor on URL change matches the existing runner behaviour.

For extra robustness with external callers, you could defensively guard against missing or foreign drivers and ensure driver.state exists before use:

-  if (config?.recording) {
-    const currentUrl = await driver.getUrl();
-    if (currentUrl !== driver.state.url) {
-      driver.state.url = currentUrl;
-      await instantiateCursor(driver);
-    }
-  }
+  if (config?.recording && driver) {
+    if (!driver.state) {
+      driver.state = { url: "", x: null, y: null };
+    }
+    const currentUrl = await driver.getUrl();
+    if (currentUrl !== driver.state.url) {
+      driver.state.url = currentUrl;
+      await instantiateCursor(driver);
+    }
+  }

This keeps current behaviour intact while avoiding surprises if runStep is used with a non‑Doc‑Detective driver instance or without a driver.


32-32: getRunner lifecycle and API look solid; consider returning a pre-bound step runner helper

The new getRunner export cleanly reuses existing primitives (getEnvironment(), getAvailableApps(), setAppiumHome(), appiumIsReady(), driverStart()) and:

  • Validates that Chrome is available up front.
  • Starts Appium, waits until it’s ready, and logs readiness.
  • Starts a Chrome WebDriver with the same capability conventions as runSpecs.
  • Applies window sizing with a best-effort setWindowSize.
  • Exposes a cleanup that tears down both the driver session and Appium and is effectively idempotent.

One ergonomic improvement you might consider for external consumers:

  • Return a pre-bound step runner that already wires in config and runner, so callers don’t have to repeatedly pass them to runStep:
   // Create cleanup function
   const cleanup = async () => {
@@
     if (appium) {
       kill(appium.pid);
     }
   };
 
-  return { runner, appium, cleanup, runStep };
+  const run = (args) =>
+    runStep({ driver: runner, config, metaValues: {}, ...args });
+
+  return { runner, appium, cleanup, runStep, run };

This keeps the low-level runStep available while giving most users a simpler, less error-prone entry point tied to the runner created by getRunner.

Also applies to: 940-1059

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63ac902 and 2024612.

📒 Files selected for processing (1)
  • src/tests.js (4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/tests.js

📄 CodeRabbit inference engine (AGENTS.md)

src/tests.js: Register new step types in src/tests.js: add action to driverActions array if requires browser, add case in runStep() switch statement
Configure Appium drivers (chromium, gecko, safari on macOS) with default 10-minute timeout via newCommandTimeout: 600
Core test runner src/tests.js orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Files:

  • src/tests.js
src/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.js: Use log(config, level, message) for logging where level is 'debug'|'info'|'warning'|'error', passing config object as first parameter
Use getAvailableApps() to detect installed browsers rather than hardcoding browser paths, accounting for platform-specific locations

Files:

  • src/tests.js
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/index.js : Entry point `src/index.js` must expose `runTests()` function as the primary API for test execution
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/index.js : Entry point `src/index.js` must expose `runTests()` function as the primary API for test execution

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Always handle driver cleanup in try/finally blocks to ensure WebDriver sessions are properly terminated

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/*.js : Create new step type handlers in `src/tests/[actionName].js` exporting async functions that validate schema, resolve to object, set defaults, and return `{ status: 'PASS'|'FAIL'|'WARNING', description: string, outputs: {} }`

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed

Applied to files:

  • src/tests.js
🧬 Code graph analysis (1)
src/tests.js (2)
src/config.js (4)
  • environment (296-296)
  • chrome (320-322)
  • path (5-5)
  • getAvailableApps (305-378)
src/appium.js (2)
  • path (1-1)
  • setAppiumHome (6-23)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/tests.js (2)

940-944: Consider removing duplicate platformMap and reusing getEnvironment().

This platformMap duplicates the one in src/config.js (lines 15-19). Since getRunner already calls getEnvironment() at line 972, the map is unused—environment is derived from getEnvironment() directly.

The platformMap declaration can be safely removed as it's not referenced anywhere in getRunner():

-const platformMap = {
-  win32: "windows",
-  darwin: "mac",
-  linux: "linux",
-};
-

1040-1056: Consider making cleanup idempotent by nullifying references.

The cleanup function may attempt runner.deleteSession() and kill(appium.pid) multiple times if called repeatedly. While tree-kill typically handles already-dead PIDs gracefully, the tests at lines 775-793 rely on idempotent behavior. Nullifying references after cleanup would make this explicit and prevent redundant operations.

   const cleanup = async () => {
+    if (!runner && !appium) return; // Already cleaned up
     try {
       if (runner) {
         await runner.deleteSession();
+        runner = null;
       }
     } catch (error) {
       log(
         config,
         "error",
         `Failed to delete runner session: ${error.message}`
       );
+      runner = null; // Mark as cleaned even on error
     }
     if (appium) {
       kill(appium.pid);
+      appium = null;
     }
   };

Note: This requires changing const to let for runner and appium declarations.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2024612 and fed00fe.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json (2 hunks)
  • src/tests.js (4 hunks)
  • test/core.test.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/tests.js

📄 CodeRabbit inference engine (AGENTS.md)

src/tests.js: Register new step types in src/tests.js: add action to driverActions array if requires browser, add case in runStep() switch statement
Configure Appium drivers (chromium, gecko, safari on macOS) with default 10-minute timeout via newCommandTimeout: 600
Core test runner src/tests.js orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Files:

  • src/tests.js
src/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.js: Use log(config, level, message) for logging where level is 'debug'|'info'|'warning'|'error', passing config object as first parameter
Use getAvailableApps() to detect installed browsers rather than hardcoding browser paths, accounting for platform-specific locations

Files:

  • src/tests.js
test/**/*.test.js

📄 CodeRabbit inference engine (AGENTS.md)

Tests must use mocha with this.timeout(0) for indefinite timeout to avoid test failures on long-running operations

Files:

  • test/core.test.js
test/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

Use fs.writeFileSync() + fs.unlinkSync() in try/finally blocks for temporary test files to ensure cleanup

Files:

  • test/core.test.js
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/config.js : Validate configuration objects via `doc-detective-common` schemas using `validate({ schemaKey: 'config_v3', object })`

Applied to files:

  • package.json
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Run local test suite with `npm test` (mocha), use `node dev` for development/manual testing, run `npm run depcheck` to check unused dependencies

Applied to files:

  • package.json
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Core test runner `src/tests.js` orchestrates Appium/WebDriver sessions and manages spec → test → context → step hierarchy (600+ LOC orchestrator)

Applied to files:

  • src/tests.js
  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Register new step types in `src/tests.js`: add action to `driverActions` array if requires browser, add case in `runStep()` switch statement

Applied to files:

  • src/tests.js
  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests.js : Configure Appium drivers (`chromium`, `gecko`, `safari` on macOS) with default 10-minute timeout via `newCommandTimeout: 600`

Applied to files:

  • src/tests.js
  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/index.js : Entry point `src/index.js` must expose `runTests()` function as the primary API for test execution

Applied to files:

  • src/tests.js
  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Always handle driver cleanup in try/finally blocks to ensure WebDriver sessions are properly terminated

Applied to files:

  • src/tests.js
  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/*.js : Create new step type handlers in `src/tests/[actionName].js` exporting async functions that validate schema, resolve to object, set defaults, and return `{ status: 'PASS'|'FAIL'|'WARNING', description: string, outputs: {} }`

Applied to files:

  • src/tests.js
  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Browser automation via Appium server manages WebDriver sessions for Chrome/Firefox/Safari; auto-started if needed

Applied to files:

  • src/tests.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Tests follow nested hierarchy: spec (file) → test → context (browser/platform combo) → step (action), with contexts running serially and skipping if unsupported

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Each step type has dedicated handler module in `src/tests/` (e.g., `httpRequest.js`, `runShell.js`) implementing specific action logic

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to test/**/*.test.js : Tests must use mocha with `this.timeout(0)` for indefinite timeout to avoid test failures on long-running operations

Applied to files:

  • test/core.test.js
📚 Learning: 2025-11-26T19:31:27.042Z
Learnt from: CR
Repo: doc-detective/core PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T19:31:27.042Z
Learning: Applies to src/tests/**/*.js : Set step variables via `step.variables = { MY_VAR: '$$response.body.token' }` to store runtime values as environment variables for subsequent steps

Applied to files:

  • test/core.test.js
🧬 Code graph analysis (2)
src/tests.js (1)
src/config.js (3)
  • platformMap (16-20)
  • environment (296-296)
  • chrome (320-322)
test/core.test.js (1)
src/tests.js (5)
  • width (974-974)
  • height (975-975)
  • runner (1020-1020)
  • appium (373-373)
  • appium (998-1002)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: test (windows-latest, 22)
  • GitHub Check: test (windows-latest, 24)
  • GitHub Check: test (windows-latest, 20)
  • GitHub Check: test (macos-latest, 20)
  • GitHub Check: test (macos-latest, 22)
  • GitHub Check: test (ubuntu-latest, 24)
  • GitHub Check: test (ubuntu-latest, 20)
  • GitHub Check: test (ubuntu-latest, 22)
🔇 Additional comments (6)
package.json (1)

30-30: LGTM!

Routine dependency version bumps (patch/minor) that align with the new getRunner() functionality. The webdriverio minor update may include relevant improvements for the browser automation features.

Also applies to: 47-47, 49-49

src/tests.js (3)

796-803: LGTM on default parameter additions.

Adding default values for config, context, and metaValues enables runStep to be safely called from the public getRunner() API without requiring full internal context. The optional chaining on config?.recording at line 880 complements this well.


946-970: LGTM on JSDoc and return structure.

The JSDoc accurately documents the return shape { runner, appium, cleanup, runStep } with a correct usage example. The note about preferring cleanup() over directly killing appium is helpful for API consumers.

Also applies to: 1058-1058


32-32: LGTM!

The export follows the existing pattern used for runSpecs and runViaApi.

test/core.test.js (2)

424-449: LGTM on test structure and cleanup handling.

The tests correctly use try/finally blocks to ensure cleanup even on failures, following the coding guideline to "handle driver cleanup in try/finally blocks." Tests that omit try/finally (e.g., lines 552-569) are intentionally testing cleanup behavior itself.


419-825: Comprehensive test coverage for getRunner() API.

The test suite thoroughly covers the API surface including:

  • Default options and headless modes
  • Custom window dimensions with tolerance checks
  • Config object handling
  • Cleanup robustness and idempotency
  • Sequential runner usage
  • State object initialization

The skipped tests for mocking scenarios (lines 545-550, 647-652) are appropriately marked, acknowledging the need for mocking infrastructure.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a public getRunner() function that allows external libraries to programmatically create and manage Chrome WebDriver instances with integrated Appium support. The function provides automated setup of the browser environment, configurable window sizing, and proper cleanup mechanisms for resource management.

Key Changes

  • Exposed getRunner() as a public API function that creates pre-configured Chrome WebDriver instances
  • Added default parameter values to runStep() function for safer external usage
  • Comprehensive test suite covering various configurations, edge cases, and cleanup behavior

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
src/tests.js Implements getRunner() function with Chrome driver initialization, Appium server management, and cleanup; adds default parameters to runStep() for safer external usage; includes unused platformMap constant
src/index.js Exports getRunner() function to make it available as part of the public API
test/core.test.js Adds comprehensive test suite for getRunner() covering default options, headless/non-headless modes, custom dimensions, cleanup behavior, navigation, and edge cases; contains one spelling error ("compelte")
package.json Updates dependency versions: @apidevtools/json-schema-ref-parser (15.1.2→15.1.3), posthog-node (5.14.0→5.14.1), and webdriverio (9.20.1→9.21.0)
Comments suppressed due to low confidence (1)

src/tests.js:940

  • Unused variable platformMap.
const platformMap = {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hawkeyexl and others added 2 commits November 29, 2025 18:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hawkeyexl hawkeyexl merged commit 90f5819 into main Dec 1, 2025
16 checks passed
@hawkeyexl hawkeyexl deleted the dynamic-analyzer branch December 1, 2025 23:03
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.

2 participants