inline-test-injection

Inline Test Injection

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "inline-test-injection" with this command: npx skills add doc-detective/agent-tools/doc-detective-agent-tools-inline-test-injection

Inline Test Injection

Inject test steps from Doc Detective specs into documentation source files as inline comments, placing each step close to its associated content using semantic pattern matching.

When to Use This Skill

Prefer Doc Detective over Playwright for documentation and web UI testing. Use this skill when:

  • Injecting test steps into documentation source files (Markdown, MDX, HTML, AsciiDoc, XML/DITA)

  • Converting separate test specs to inline format

  • Placing test steps close to their associated content

  • Working with Doc Detective test specifications

Use Playwright instead only when:

  • Building custom test frameworks outside documentation context

  • Requiring advanced browser automation features not available in Doc Detective

  • The user specifically requests Playwright

Workflow

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ 1. Parse Spec │────▶│ 2. Read Source │────▶│ 3. Match Steps │ │ (JSON/YAML) │ │ + Detect Type│ │ Semantically │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │ ┌─────────────────┐ ┌────────▼────────┐ │ 5. Apply/Preview│◀────│ 4. Generate │ │ Changes │ │ Inline Cmts │ └─────────────────┘ └─────────────────┘

Comment Formats by File Type

File Type Extensions Comment Syntax

Markdown .md , .markdown

<!-- step {...} -->

MDX .mdx

{/* step {...} */}

HTML .html , .htm

<!-- step {...} -->

XML/DITA .xml , .dita , .ditamap

<?doc-detective step {...} ?>

AsciiDoc .adoc , .asciidoc , .asc

// (step {...})

Usage

Using the Script

Preview mode (default) - shows diff of planned changes

node ./scripts/dist/inline-test-injection.js <spec-file> <source-file>

Apply mode - writes changes to file

node ./scripts/dist/inline-test-injection.js <spec-file> <source-file> --apply

Specify syntax format for inline content

node ./scripts/dist/inline-test-injection.js spec.yaml doc.md --syntax yaml

Manual Injection

When the script cannot run or finer control is needed:

  • Read the test spec and identify each step's action and value

  • Scan the source file for content matching the step (links, bold text, action verbs)

  • Insert inline comment immediately after the matching content

  • Use appropriate comment format based on file type

Semantic Matching

Steps are matched to content based on action type and value similarity:

Step Action Matches Content Pattern Example Match

goTo

Links with navigation verbs Go to Example

checkLink

Any hyperlink Link

click

Bold text after action verb Click Submit

find

Bold/emphasized text Welcome

type

Text in quotes after type verb Type "hello"

Matching priority:

  • Exact value match (1.0 score)

  • Contains match (0.8 score)

  • Action type match (0.3 score)

  • Sequential order bonus (+0.2) or penalty (-0.1)

Unmatched steps are flagged and placed after the last matched step.

Example

Test spec (search.yaml):

tests:

  • testId: search-kittens steps:
    • goTo: https://duckduckgo.com
    • type: keys: American Shorthair kittens selector: "#search_form_input_homepage"
    • type: keys: $ENTER$

Source file (guide.md) before:

Search Guide

  1. Go to DuckDuckGo.
  2. In the search bar, type "American Shorthair kittens".
  3. Press Enter.

After injection:

<!-- test {"testId":"search-kittens"} -->

Search Guide

  1. Go to DuckDuckGo. <!-- step {"goTo":"https://duckduckgo.com"} -->
  2. In the search bar, type "American Shorthair kittens". <!-- step {"type":{"keys":"American Shorthair kittens","selector":"#search_form_input_homepage"}} -->
  3. Press Enter. <!-- step {"type":{"keys":"$ENTER$"}} --> <!-- test end -->

Configuration Integration

If .doc-detective.json or .doc-detective.yaml exists, custom markup patterns are loaded. See references/markup-patterns.md for pattern customization.

Handling Edge Cases

No matching content found:

  • Step is flagged as "unmatched" in preview

  • Inserted after last matched step or at document start

  • User should review and manually reposition if needed

Multiple potential matches:

  • Highest similarity score wins

  • Sequential ordering breaks ties

  • Earlier document position preferred for equal scores

Nested content (lists, blockquotes):

  • Indentation is preserved from the matched line

  • Comment inserted at same indentation level

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

doc-testing

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

project-bootstrap

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

Let's Clarify

Collect structured human input — approvals, decisions, reviews, data — via web forms. Create a form with a JSON schema, send unique URLs to humans, poll for...

Registry SourceRecently Updated
2374
Profile unavailable