devtools::test passes but devtools::check fails

:wave: @jennahamlin!

Generally for such problems (tests passing in a context and not in another) I like to refer to a GitHub thread collecting such cases, where one can often see something relevant. However, I also had a look at your package out of curiosity.

The problem was that the order of packages loading was different in the two contexts. When running tests with devtools::test(), as_tibble() was the function you wanted which is the one from tidytree. When running tests with devtools::check(), as_tibble() was the as_tibble() from tibble. The fix is to add the namespace before the function i.e. write tidytree::as_tibble(), and also to import tidytree in DESCRIPTION (it was already an indirect dependency of your package). I made a PR to your package.

I found this more or less by chance by looking a bit at how one would convert an object of class phylo to a data.frame, and looking at tidytree docs.

As side-notes,

  • in your original test file there's the context() command, that isn't recommended anymore.
  • Also note that testthat::expect_is() is getting superseded in testthat 3.0.0 (not on CRAN yet). To learn more about testthat changes, and if you have one hour free, watch the webinar.