Open MatthieuStigler opened 2 years ago
There are two parts to this problem:
testthat::snapshot_review()
is the file
argument, and this is the path argument, so the message should name the argument: "Run testthat::snapshot_review(path='tests/testthat/_snaps/external_file/') to review changes"2. The first argument to `testthat::snapshot_review()` is the `file` argument, and this is the path argument, so the message should name the argument: "Run testthat::snapshot_review(path='tests/testthat/_snaps/external_file/') to review changes"
Looking at the code, this is also wrong. The path must be the absolute path to "tests/testthat/" and the code will append "_snaps".
The function is meant to be used from the root directory of the package, so the default path is "tests/testthat". If used in some other way, the path to "_snaps" has to be specified. The function snapshot_meta
does not report a non-existent path and simply reports no files.
In the example above, the correct invokation is:
testthat::snapshot_review('external_file/', path=".")
or
testthat::snapshot_review('external_file/', path=f)
I think the error should report:
Snapshot of `testcase` to 'external_file/base-histogram.svg' has changed
Run `testthat::snapshot_review('external_file/', path = '/tmp/XXXXX')` to review changes
where '/tmp/XXXXX' is the dirname of the failing testcase removing "_snaps/external_file/base-histogram.svg".
The path argument in the error could be dropped if it matches file.path(getwd(), "tests/testthat")
as that is the default.
When running
testthat::test_file()
on an external file (i.e. not linked to a package). a change in the snaphot will trigger a error message:The path indicated in
testthat::snapshot_review('external_file/')
is however non-informative, leading to No snapshots to update. This does not seem to be just a path issue: adding the correct full path still lead to the same error. It seems on the other hand that using the argumentpath
will solve the problem?Reproducible code ran with testthat 3.1.2, not reprexable though:
Example output: