{"id":14069106,"url":"https://github.com/ThinkR-open/testdown","last_synced_at":"2025-07-30T05:31:25.053Z","repository":{"id":45097467,"uuid":"160729152","full_name":"ThinkR-open/testdown","owner":"ThinkR-open","description":"Turn your 'testthat' results into a Bookdown.","archived":false,"fork":false,"pushed_at":"2023-04-11T06:58:27.000Z","size":2621,"stargazers_count":27,"open_issues_count":6,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-19T19:07:54.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://thinkr-open.github.io/testdown/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThinkR-open.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-06T20:38:04.000Z","updated_at":"2025-01-23T03:35:50.000Z","dependencies_parsed_at":"2024-08-13T07:14:58.961Z","dependency_job_id":"4b92ea4a-68e0-4f8c-9013-d146251f2736","html_url":"https://github.com/ThinkR-open/testdown","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ThinkR-open/testdown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Ftestdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Ftestdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Ftestdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Ftestdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThinkR-open","download_url":"https://codeload.github.com/ThinkR-open/testdown/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Ftestdown/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267815187,"owners_count":24148356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:06:36.632Z","updated_at":"2025-07-30T05:31:24.510Z","avatar_url":"https://github.com/ThinkR-open.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\", \n  eval = FALSE\n)\n# Copy reference/images to man/images\n# reference folder is required to work with pkgdown\nif (!dir.exists(\"man/figures\")) {dir.create(\"man/figures\")}\nfile.copy(list.files(\"reference/figures\", full.names = TRUE),\n          \"man/figures\", overwrite = TRUE)\n```\n\n# testdown \u003cimg src=\"man/figures/logo.png\" align=\"right\" alt=\"\" width=\"120\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)\n[![R-CMD-check](https://github.com/ThinkR-open/testdown/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ThinkR-open/testdown/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nThe goal of `{testdown}` is to generate a bookdown report of `{testthat}` results\n\n## Installation\n\nYou can install the dev version of `{testdown}` \n\n- from r-universe\n\n```r\n# Enable universe(s) by thinkr-open\noptions(repos = c(\n    thinkropen = 'https://thinkr-open.r-universe.dev',\n    CRAN = 'https://cloud.r-project.org'))\n\n# Install some packages\ninstall.packages('testdown')\n```\n\n- from GitHub with:\n\n``` r\nremotes::install_github(\"ThinkR-open/testdown\")\n```\n\n## About\n\nThis package has two exported functions: \n\n### `test_down()`\n\nThis function turns the `{testthat}` results into a `{bookdown}` report. \nIt takes:\n\n+ A `project_name`, which is the name you want to give to the project. \nThe default is `NULL`, which will then be converted to `basename(here::here())`.\n+ An `author`, if you want your report to be have an author name.\nDefault is NULL, and then the report won't have any name on it.\n+ `pkg`, the path to the package that will be documented. \nDefault is `here::here()`\n+ `environment`, a name for the testing environment.\nDefault is `here::here()`\n+ `book_path`, the folder where you want the `{bookdown}` report to be created. \nDefault is `\"tests/testdown\"`.\n+ `with_help` Should the help appendix be added? \nDefault is `TRUE`.\n+ `open` Should the report be opened once compiled? \nDefault is `interactive()`.\n\n### `test_down_example()`\n\nThis function will compile the report for an example package contained inside `{testdown}`.\n\n## Custom `{testdown}` roxygen tags\n\nYou can add a `description` to your tests using the roxygen tag `@description`.\nNote that this test __must__ be on the line just before the expectation. \n\nHere is an example: \n\n```{r eval = FALSE}\ntest_that(\"hello_world() works\", {\n  \n  #' @description Testing that hello_world(\"colin\") returns \"Hello world, my name is colin!\"\n  expect_equal(hello_world(\"colin\"), \"Hello world, my name is colin!\")\n  \n  #' @description Testing that hello_world(\"colin\") returns a character vector\n  expect_is(hello_world(\"colin\"), \"character\")\n  \n  #' @description Testing that hello_world(\"colin\") has World in it\n  expect_match(hello_world(\"colin\"), \"World\")\n  \n  #' @description Testing that hello_world(\"colin\") has Hello in it\n  expect_match(hello_world(\"colin\"), \"Hello\")\n})\n```\n\n```{r child = \"inst/testdownhelp.md\", eval = TRUE}\n\n```\n\n## Writing custom expectation\n\nFor reliable results, all expectations should start by `expect`, notably if you need to count the skipped tests. \nIn other words, the skipped expectations count relies on counting all the functions starting with `expect`, so naming custom expectation differently will prevent this count from being correct.  \n\n## Known limitations\n\n`{testdown}` report relies on `{testthat}` and the results are based on these outputs. \n\nHere are known example of results that will be discarded by `{testthat}` and hence will make `{testdown}` behave in a weird way. \n\n+ Using `{withr}`\n\n```{r}\ntest_that(\"Files exist\", {\n  with_dir(\n    \"new/dir\",\n    {\n      #' @description Checking that style.css is created\n      expect_file_exists(\"tests/testdown/style.css\")\n      #' @description Checking that _bookdown.yml is created\n      expect_file_exists(\"tests/testdown/_bookdown.yml\")\n      #' @description Checking that _output.yml is created\n      expect_file_exists(\"tests/testdown/_output.yml\")\n    }\n  )\n})\n```\n\nAs testthat doesn't count the expectations from `with_dir`, this will make the `{testdown}` result weird.\nAlways add the expectations at the top level of your test_that. \n\n+ Loops\n\nSame goes with for loops:\n\n```{r eval = FALSE}\nfor (i in names(df)){\n    #' @description Checking the names of the output are correct\n    expect_true(\n      i %in% c(\n        \"context\",\n        \"test\",\n        \"expectation\",\n        \"description\",\n        \"location\",\n        \"test_time\",\n        \"result\",\n        \"file\",\n        \"message\"\n      )\n    )\n  }\n```\n\nIf ever you use this format, `{testthat}` won't catch the tests, so they won't be reported.\n\n+ HTML expectations\n\nAs testdown render the text straight in html, if your expecatation contains html, it will break the rendering. \nFor example, the following test will break the rendering:\n\n```{r}\nexpect_match(\n  tag, \n  \"\u003ch2\u003ethis\u003c/h2\u003e\"\n)\n```\n\n## Sponsor\n\nThe development of this package has been sponsored by: \n\n\u003ca href = \"https://www.servier.fr/\"\u003e\u003cimg src = \"man/figures/servier.png\"\u003e\u003c/img\u003e\u003c/a\u003e\n\n\n\n## CoC\n\nPlease note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\nBy participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkR-open%2Ftestdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThinkR-open%2Ftestdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkR-open%2Ftestdown/lists"}