Skip to content

docs: update tdd-workflow/SKILL.md error-testing patterns#12

Merged
jonthegeek merged 4 commits intomainfrom
copilot/update-tdd-workflow-skill-md
Mar 20, 2026
Merged

docs: update tdd-workflow/SKILL.md error-testing patterns#12
jonthegeek merged 4 commits intomainfrom
copilot/update-tdd-workflow-skill-md

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

The tdd-workflow skill documented bare expect_error() calls and a stale standalone section that didn't reflect how this project actually tests errors. Updates .github/skills/tdd-workflow/SKILL.md:

  • ### Conditions rewritten — three subsections by error source:
    • Package errors (stbl-style via .pkg_abort()) → expect_pkg_error_snapshot()
    • stbl validation errors → stbl::expect_pkg_error_classes()
    • Third-party errors → expect_error() / expect_snapshot()
  • ### Snapshot tests cleaned up — removed the expect_error()-inside-expect_snapshot() example and its cross-reference; section now covers only non-error snapshots
  • ## Testing errors with stbl::expect_pkg_error_classes() removed — fully absorbed into the updated Conditions section
  • mypkgpkgskills — replaced placeholder names in withr and local_pkg() examples
Original prompt

This section details on the original issue you should resolve

<issue_title>docs: update tdd-workflow/SKILL.md</issue_title>
<issue_description>## Summary

As an AI agent working on an R package, in order to test errors correctly
using stbl-style conventions, I would like the tdd-workflow skill to
reflect actual error-testing patterns rather than documenting bare
expect_error() calls.

Details

Make the following changes to .github/skills/tdd-workflow/SKILL.md:

A1. Replace any generic "mypkg" references with "pkgskills"

The skill is the live reference for this project. Generic placeholder names
will be replaced with whisker template variables when the installer function
copies it to inst/templates/. For now, use "pkgskills" so the live skill is
accurate.

A2. Replace the "### Conditions" section

The current section lists bare expect_error() calls that don't reflect how
this project actually tests errors. Replace it entirely. The new section has
three subsections — one per error source — followed by the existing
warning/message expectations.

New section text:

### Conditions

**Errors thrown by this package** (via `.pkg_abort()`) should always be tested
with `expect_pkg_error_snapshot()` (defined in
`tests/testthat/helper-expectations.R`), which captures both the error class
hierarchy and the user-facing message in one snapshot:

```r
test_that("process_data() errors on empty input (#42)", {
  expect_pkg_error_snapshot(
    process_data(data.frame()),
    "empty_input"
  )
})
```

Pass `transform = .transform_path(path)` to scrub volatile values (e.g. temp
paths) from the snapshot before comparison.

**Errors thrown by `stbl`** (via `stbl::to_*()` / `stbl::stabilize_*()`)
should be tested with `stbl::expect_pkg_error_classes()`. Since the message
text is controlled by `stbl`, only the class hierarchy needs to be asserted:

```r
test_that("process_data() errors on non-integer page_size (#43)", {
  stbl::expect_pkg_error_classes(
    process_data(sample_data, page_size = "abc"),
    "stbl",
    "incompatible_type"
  )
})
```

**Errors from other packages** can be tested with `expect_error()`, optionally
wrapped in `expect_snapshot()` to lock down the message text:

```r
expect_error(code, "pattern")
expect_error(code, class = "some-error-class")

# Lock down both class and message text:
test_that("fetch_records errors on invalid input (#456)", {
  expect_snapshot(
    (expect_error(
      fetch_records("not valid input"),
      class = "pkg-error"
    ))
  )
})
```

```r
expect_warning(code)
expect_no_warning(code)
expect_message(code)
expect_no_message(code)
```

A3. Remove the error example from "### Snapshot tests"

The "### Snapshot tests" section currently includes an expect_error() wrapped
in expect_snapshot() example, with a cross-reference to "Testing errors with
stbl::expect_pkg_error_classes()". Remove both the error example block and
the cross-reference line entirely. The section should only cover non-error
snapshot use cases.

A4. Remove the "## Testing errors with stbl::expect_pkg_error_classes()" section

This standalone section (currently near the bottom, before ## withr patterns)
is fully absorbed into the updated "### Conditions" section. Delete it entirely.</issue_description>

<agent_instructions>This change does not involve any R code changes, so don't run the test suite before/after this change.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Copilot AI changed the title [WIP] Update tdd-workflow skill documentation docs: update tdd-workflow/SKILL.md error-testing patterns Mar 20, 2026
Copilot AI requested a review from jonthegeek March 20, 2026 12:13
Copy link
Copy Markdown
Contributor

@jonthegeek jonthegeek left a comment

Choose a reason for hiding this comment

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

Looks great as long as we didn't somehow break checks!

@jonthegeek jonthegeek marked this pull request as ready for review March 20, 2026 12:17
@jonthegeek jonthegeek removed their assignment Mar 20, 2026
@jonthegeek jonthegeek merged commit f1f70d8 into main Mar 20, 2026
8 of 9 checks passed
@jonthegeek jonthegeek deleted the copilot/update-tdd-workflow-skill-md branch March 20, 2026 12:27
Copilot AI added a commit that referenced this pull request Mar 20, 2026
Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/789f1d81-1bb1-49a2-8b81-0f1da15927d0
Copilot AI added a commit that referenced this pull request Mar 20, 2026
Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/1878843d-e61b-40e9-8765-29da53362ba4
Copilot AI added a commit that referenced this pull request Mar 20, 2026
Installs the github skill (gh CLI + commit message guidance) into a
project with a single function call. Delegates to .use_skill() following
the same pattern as use_skill_document().

- Closes #12

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/6197315a-9a07-4197-8bb8-e3f0847d980a
Copilot AI added a commit that referenced this pull request Mar 22, 2026
…is called (#12)

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/dab485c2-910b-4aa0-9d96-4b48bb125778
Copilot AI added a commit that referenced this pull request Mar 22, 2026
…epr dep (#12)

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/c2f4a840-8e65-4103-bc83-83565ac39714
Copilot AI added a commit that referenced this pull request Mar 22, 2026
Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/a090f86d-a474-436a-9365-6ae42e7c7ec9
jonthegeek added a commit that referenced this pull request Mar 22, 2026
* Initial plan

* feat: add use_skill_search_code() (#12)

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/1878843d-e61b-40e9-8765-29da53362ba4

* feat: add astgrepr to Suggests via desc when use_skill_search_code() is called (#12)

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/dab485c2-910b-4aa0-9d96-4b48bb125778

* feat: use rlang::check_installed() + usethis::use_package() for astgrepr dep (#12)

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/c2f4a840-8e65-4103-bc83-83565ac39714

* fix: replace #12 with #20 in tests and NEWS

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/a090f86d-a474-436a-9365-6ae42e7c7ec9

* refactor: simplify astgrepr dep check; use desc_get_deps in tests

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/1a0474a2-248f-453f-96b7-7a23d1f9fe15

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
jonthegeek added a commit that referenced this pull request Mar 22, 2026
* Initial plan

* feat: add use_skill_github()

Installs the github skill (gh CLI + commit message guidance) into a
project with a single function call. Delegates to .use_skill() following
the same pattern as use_skill_document().

- Closes #12

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/6197315a-9a07-4197-8bb8-e3f0847d980a

* Apply suggestions from code review

Co-authored-by: Jon Harmon <jonthegeek@gmail.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Co-authored-by: Jon Harmon <jonthegeek@gmail.com>
jonthegeek added a commit that referenced this pull request Mar 22, 2026
* Initial plan

* feat: add use_skill_implement_issue() (#12)

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/api2r/pkgskills/sessions/789f1d81-1bb1-49a2-8b81-0f1da15927d0

* air format

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Co-authored-by: Jon Harmon <jonthegeek@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

docs: update tdd-workflow/SKILL.md

2 participants