1

Is there a way to manually clear the pester TestDrive, other than something like Remove-Item "TestDrive:\" -Recurse -Force

Kevin Holtkamp
  • 479
  • 4
  • 17
  • What is the reason you are asking? Seems simple and intuitive enough. – Daniel Apr 26 '22 at 17:09
  • This is a very rudimentary and error prone way, for example if a file is somehow in use, or the `Remove-Item` call fails in some other way. It would be nice to have an "official" way to do it – Kevin Holtkamp Apr 26 '22 at 17:15

1 Answers1

1

AFAIK there isn't a function to trigger a clear of TestDrive, so yes I would recommend using something like Remove-Item $TestDrive -Recurse -Force if you had a specific need to.

However you should also be aware that a TestDrive is scoped to a Describe or Context block and automatically cleaned up at the end of those blocks. So if you want to avoid conflicts between different usages of TestDrive just have those test in different Context blocks.

Mark Wragg
  • 22,105
  • 7
  • 39
  • 68
  • If i read the documentation correctly, it will only reset for the topmost `Describe` or `Context` block, so multiple `Context` blocks inside a `Describe`, which is what i am using, would not work – Kevin Holtkamp Apr 27 '22 at 06:18