Skip to main content
Version: v5

Visual Studio Code

Using Visual Studio Code with the latest PowerShell extension provides a great experience for writing PowerShell code. The extension includes Pester-specific features to improve the way you write, run and debug Pester tests.

Code lens​

With the Pester: Code Lens setting enabled, VSCode will show Run tests or Debug tests links above your Pester blocks for quick execution. Starting with Pester 5 this also works on individual tests. You can even run tests that are marked as skipped by running them individually.

Shows a single test being run using the new Code Lens

To enable the improved code lens for Pester 5 you need to disable the "Use Legacy Code Lens" setting which is enabled by default.

  1. In Visual Studio Code, open File | Preferences | Settings (⌘/Ctrl + ,)
  2. In the Settings window, navigate to the Extensions | PowerShell section.
  3. Uncheck the Pester: Use Legacy Code Lens checkbox.
  4. Close the Settings window.

Output verbosity​

You can control the output verbosity level in VSCode output, or let it inherit from PesterPreference.

Shows a run with normal preference that shows only errors

Pester-blocks are recognized by the PowerShell-extension to simplify navigation in your test files.

  • The Outline panle shows an overview of your Pester-blocks.
    Shows a outline of Pester block structure in the sidepanel

  • Your current location in easily identified using breadcrumbs or the sticky scroll features.
    Shows nested blocks as sticky lines above the current line in the editor

  • Context, Describe and It blocks are all searchable using Go to symbol commands.
    Shows a search result for Help is found-test using the Go To Symbol in Workspace command