Skip to content

devtools::test() with filter argument creates empty _snaps folder when no snapshots are usedΒ #1917

@slager

Description

@slager

None of my tests use snapshots. The initial state of my testthat directory is that there is no _snaps subdirectory.

When I run devtools::test() I can see that the _snaps folder is created and then removed during the testing process.

When I run devtools::test() with the filter argument to run a subset of tests, the _snaps folder is created but not removed.

To reproduce, clone the latest version of this testthat repo, open testthat.Rproj, and step through the following code:

# setup paths
snaps_path <- file.path('tests', 'testthat', '_snaps')
snaps_backup_path <- file.path('tests', 'testthat', '_snaps_backup')

# backup existing _snaps folder
file.rename(snaps_path, snaps_backup_path)
#[1] TRUE

# _snaps folder doesn't exist now
file.exists(snaps_path)
#[1] FALSE

# these tests contain no snapshots
devtools::test(filter = '^bare$')
#β„Ή Testing testthat
#Starting 1 test process
#βœ” | F W  S  OK | Context
#βœ” |          4 | bare                                                                  
#                                                                                      
#══ Results 
#Duration: 2.3 s
#[ FAIL 0 | WARN 0 | SKIP 0 | PASS 4 ]

# _snaps folder got created
file.exists(snaps_path)
#[1] TRUE

# restore existing _snaps folder
unlink(snaps_path, recursive = TRUE)
file.rename(snaps_backup_path, snaps_path)
#[1] TRUE

See also:

#1180

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions