As part of some work to migrate from a proprietary set of build tools for a particular website to the wonderful eleventy, we need to make sure we remove all the old crufty markup and weird variables and replace them with nice new markdown and nunjucks style double curly braces - moustaches if you will. We use variables to keep product name, versions, contact addresses etc. updateable from one single source of truth.

This is a snippet of a Pester test I wrote to make sure that all of the generated content, once it has been processed by eleventy, has been handled correctly and we haven't mistyped a variable name. If all is well, there should be no moustache variables left in the final output.


It 'Replaced all moustache markup' {

    Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath _site) -Filter *.html |
    Get-Content |
    Select-String 'moustache' |
    Should -Be $null 
}

The test is quite slow because it's loading each file content individually and searching each file for matches but it does seem to be reliable in making sure we don't accidentally break something as we migrate.