Boost your productivity with Pester snippets

Authoring Pester tests is easy as it is, but if you are lucky enough to own a copy of ISESteroids 2 it now became even easier. Pester version 3.3.1 adds code snippets for you to use.

ISESteroids comes with TAB expansion of code snippets which is really easy to use. Actually this is how easy it is:

You just type a shortcut and press TAB to expand it.

There is also little to memorize. The Describe is dsc, the Context is ctx and the assertions use the first letter of each word for shortcut. The only exception is Should Be NullOrEmpty which is just sbn and not sbnoe.

Installing the snippets

Installing the snippets is easy as well. Update your copy of Pester to the latest version (3.3.1) and import it before importing the latest version of ISESteroids (2.0.13.6).

The easiest way to do that is importing both modules in your ISE profile.

This is how you do that:

  • Expand additional menu to access All tools
  • Open the ISE profile
  • Add calls to Import-Module as shown in picture
  • Restart ISE

As noted by Tobias Weltner, author of ISESteroids: Beginning with the current release 2.0.13.6 loading other modules before ISESteroids should not matter anymore. Loading snippets is still done on startup only though, so you have to load Pester first.

Share on: