Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshot testing bug (?): "no snapshotter active" #1226

Closed
raphael-lorenzdelaigue opened this issue Nov 9, 2020 · 2 comments
Closed

Snapshot testing bug (?): "no snapshotter active" #1226

raphael-lorenzdelaigue opened this issue Nov 9, 2020 · 2 comments

Comments

@raphael-lorenzdelaigue
Copy link

I created a new custom package following the guidelines here: https://r-pkgs.org/whole-game.html
And tried to perform snapshot testing on a function following this vignette: https://testthat.r-lib.org/articles/snapshotting.html.
However when trying to run the test I get the following message

No snapshotter active. Current value: 
[...]

The current value makes sense for my function, but the _snaps folder and corresponding *.R file are not created. I get the same message if re-running the test.

Same thing if I try with another function, for example the "bullets" example function from the vignette.

Example code:

test_that("bullets", {
  local_edition(3)
  expect_snapshot(cat(bullets("a")))
})

Example output:

No snapshotter active. Current value: 
Code
    cat(bullets(\"a\"))
Output
  <ul>
      <li>a</li>
  </ul>
-- Skip (???): bullets---------------------------------------------------------
Reason: empty test

Is there a way to activate the snapshotter? Or is this just a bug?

I am quite new to R/RStudio so I might have missed out on something obvious to try out. Happy for any kind of advice.

@hadley
Copy link
Member

hadley commented Nov 9, 2020

You have to test the whole file with test_file() or similar. I'll make that clearer in the warning message.

@raphael-lorenzdelaigue
Copy link
Author

Thanks a lot, solved the problem.
Thanks also for the nice feature, came just at the right moment for me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants