posit-dev / posit-dev/positron
Use prefix from `describe()` in BDD-style testthat tests
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.3k
- Forks
- 184
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 206
Description
System details:
Positron and OS details:
Positron Version: 2025.03.0 (Universal) build 116
Code - OSS Version: 1.96.0
Commit: 7f0f93873e8b24c9f393bb3586724f4783c5e72c
Date: 2025-03-01T18:51:44.014Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Darwin arm64 24.3.0
Interpreter details:
version R version 4.4.2 (2024-10-31)
os macOS Sequoia 15.3.1
system aarch64, darwin20
Describe the issue:
I'm loving the new features around R package tests! I also really like BDD-style tests, which are supported with describe() and it() in testthat.
When using these kinds of tests, however, the names used in the test results do not include the prefix from describe(), which ruins readability.
Steps to reproduce the issue:
In a basic, bare R package, include these tests:
division <- function(x, y) x * y
describe("division()", {
it("can divide two numbers", {
expect_equal(10 / 2, division(10, 2))
})
it("throws for division by 0", {
expect_error(division(10, 0))
})
})
Expected or desired behavior:
When evaluated through devtools::test(), you'll get errors like these:
── Failure: division(): can divide two numbers ────────────────────────────
10/2 (`actual`) not equal to division(10, 2) (`expected`).
`actual`: 5.0
`expected`: 20.0
── Failure: division(): throws for division by 0 ──────────────────────────
`division(10, 0)` did not throw the expected error.
Note that the test titles include the prefix from describe(): devision(): _____.
In the Test Results panel, these tests will appear only as
- can divide two numbers
- throws for division by 0
which quickly becomes confusing in a large test suite.
It'd be really nice if display name could include the prefix:
- division(): can divide two numbers
- division(): throws for division by 0
Were there any error messages in the UI, Output panel, or Developer Tools console?
No
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example in a bare R package with devtools::test(), then inspect how the Test Results panel receives and displays testthat BDD results. Done means the displayed names include the describe() prefix, such as “division(): can divide two numbers” and “division(): throws for division by 0”.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r, typescript
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100