Where to write files during testing

You should only write files inside the session temp directory.

  • withr::local_tempfile(): Creates a file within the session temp directory whose lifetime is tied to the “local” environment – in this case, the execution environment of an individual test.

  • withr::local_tempdir(): Create a self-deleting temporary directory and write intentionally-named files inside this directory.