PageSourceSearch

https://pester.dev/assets/js/e3be4c4a.e376823a.js

js pester.dev collected 2026-10-03 19:39:26 UTC 9,476 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkpester_docs=self.webpackChunkpester_docs||[]).push([["5507"],{3945(e,s,i){i.r(s),i.d(s,{metadata:()=>n,default:()=>h,frontMatter:()=>o,contentTitle:()=>a,toc:()=>l,assets:()=>d});var n=JSON.parse('{"id":"migrations/breaking-changes-in-v5","title":"Breaking changes in v5","description":"Pester v5 included an all-new runtime which lead to some breaking changes in syntax and features for existing users. See this list of breaking changes when upgrading to Pester v5","source":"@site/docs/migrations/breaking-changes-in-v5.mdx","sourceDirName":"migrations","slug":"/migrations/breaking-changes-in-v5","permalink":"/docs/migrations/breaking-changes-in-v5","draft":false,"unlisted":false,"editUrl":"https://github.com/pester/docs/edit/main/docs/migrations/breaking-changes-in-v5.mdx","tags":[],"version":"current","frontMatter":{"id":"breaking-changes-in-v5","title":"Breaking changes in v5","description":"Pester v5 included an all-new runtime which lead to some breaking changes in syntax and features for existing users. See this list of breaking changes when upgrading to Pester v5"},"sidebar":"docs","previous":{"title":"Pester v4 to v5","permalink":"/docs/migrations/v4-to-v5"},"next":{"title":"Pester v3 to v4","permalink":"/docs/migrations/v3-to-v4"}}'),t=i(1987),r=i(7008);let o={id:"breaking-changes-in-v5",title:"Breaking changes in v5",description:"Pester v5 included an all-new runtime which lead to some breaking changes in syntax and features for existing users. See this list of breaking changes when upgrading to Pester v5"},a,d={},l=[{value:"Actual breaking changes",id:"actual-breaking-changes",level:2},{value:"Deprecated features",id:"deprecated-features",level:3},{value:"Additional issues to be solved future releases",id:"additional-issues-to-be-solved-future-releases",level:3}];function c(e){let s={a:"a",code:"code",h2:"h2",h3:"h3",li:"li",p:"p",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.h2,{id:"actual-breaking-changes",children:"Actual breaking changes"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:["The Parameters of ",(0,t.jsx)(s.code,{children:"Invoke-Pester"})," changed significantly, but a compatibility parameter set was added to allow all the v4 parameters to be used, e.g. like this ",(0,t.jsx)(s.code,{children:'Invoke-Pester -Script $testFile -PassThru -Verbose -OutputFile $tr -OutputFormat NUnitXml -CodeCoverage "$tmp/*-*.ps1" -CodeCoverageOutputFile $cc -Show All'}),". Be aware of these limitations and notes:","\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:["The compatibility is not 100%, neither ",(0,t.jsx)(s.code,{children:"-Script"})," not ",(0,t.jsx)(s.code,{children:"-CodeCoverage"})," take hashtables, they just take a collection of paths."]}),"\n",(0,t.jsxs)(s.li,{children:["The ",(0,t.jsx)(s.code,{children:"-Strict"})," parameter and ",(0,t.jsx)(s.code,{children:"-PesterOption"})," are ignored."]}),"\n",(0,t.jsxs)(s.li,{children:["The ",(0,t.jsx)(s.code,{children:"-Output"})," \\ ",(0,t.jsx)(s.code,{children:"-Show"})," parameter takes all the values, but translates only the most used options to Pester 5 compatible options, otherwise it uses ",(0,t.jsx)(s.code,{children:"Detailed"})," output. It also allows all the Pester 5 output options, to allow you to use ",(0,t.jsx)(s.code,{children:"Diagnostic"})," during migration."]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"This whole Legacy-parameter set is deprecated"})," and prints a warning when used. For more options and the Advanced interface see ",(0,t.jsx)(s.a,{href:"./v4-to-v5#simple-and-advanced-interface",children:"simple and advanced interface"})," above on how to invoke Pester."]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(s.li,{children:"PowerShell 2 is no longer supported"}),"\n",(0,t.jsxs)(s.li,{children:["Legacy syntax ",(0,t.jsx)(s.code,{children:"Should Be"})," (without ",(0,t.jsx)(s.code,{children:"-"}),") is removed, see ",(0,t.jsx)(s.a,{href:"./v3-to-v4",children:"Migrating from Pester v3 to v4"})]}),"\n",(0,t.jsxs)(s.li,{children:["Mocks are scoped based on their placement, not in 
1whole ",(0,t.jsx)(s.code,{children:"Describe"})," / ",(0,t.jsx)(s.code,{children:"Context"}),". The count also depends on their placement. See ",(0,t.jsx)(s.a,{href:"../usage/mocking#mocks-are-scoped-based-on-their-placement",children:"mock scoping"})]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"Assert-VerifiableMocks"})," was removed, see ",(0,t.jsx)(s.a,{href:"../usage/mocking#should-invoke",children:"Should-Invoke"})]}),"\n",(0,t.jsxs)(s.li,{children:["All code placed in the body of ",(0,t.jsx)(s.code,{children:"Describe"})," outside of ",(0,t.jsx)(s.code,{children:"It"}),", ",(0,t.jsx)(s.code,{children:"BeforeAll"}),", ",(0,t.jsx)(s.code,{children:"BeforeEach"}),", ",(0,t.jsx)(s.code,{children:"AfterAll"}),", ",(0,t.jsx)(s.code,{children:"AfterEach"})," will run during discovery and it's state might or might not be available to the test code, see ",(0,t.jsx)(s.a,{href:"../usage/discovery-and-run",children:"Discovery and Run"})]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"-Output"})," parameter has reduced options to ",(0,t.jsx)(s.code,{children:"None"}),", ",(0,t.jsx)(s.code,{children:"Normal"}),", ",(0,t.jsx)(s.code,{children:"Detailed"})," and ",(0,t.jsx)(s.code,{children:"Diagnostic"}),". ",(0,t.jsx)(s.code,{children:"-Show"})," alias is removed"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"-PesterOption"})," switch is removed"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"-TestName"})," switch is replaced with ",(0,t.jsx)(s.code,{children:"-FullNameFilter"})," switch"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"-Script"})," option was renamed to ",(0,t.jsx)(s.code,{children:"-Path"})," and takes paths only, it does not take hashtables. For parametrized scripts, see ",(0,t.jsx)(s.a,{href:"../usage/data-driven-tests#providing-external-data-to-tests",children:"Providing external data to tests"})]}),"\n",(0,t.jsxs)(s.li,{children:["Using ",(0,t.jsx)(s.code,{children:"$MyInvocation.MyCommand.Path"})," to locate your script in ",(0,t.jsx)(s.code,{children:"BeforeAll"})," does not work. This does not break it for your scripts and modules. Use ",(0,t.jsx)(s.code,{children:"$PSScriptRoot"})," or ",(0,t.jsx)(s.code,{children:"$PSCommandPath"}),". See ",(0,t.jsx)(s.a,{href:"../usage/importing-tested-functions#migrating-from-pester-v4",children:"Migrating from Pester v4"})," or the ",(0,t.jsx)(s.a,{href:"https://jakubjares.com/2020/04/11/pester5-importing-ps-files/",children:"importing ps files"})," article for detailed information."]}),"\n",(0,t.jsxs)(s.li,{children:["Should ",(0,t.jsx)(s.code,{children:"-Throw"})," is using ",(0,t.jsx)(s.code,{children:"-like"})," to match the exception message instead of .Contains. Use ",(0,t.jsx)(s.code,{children:"*"})," or any of the other ",(0,t.jsx)(s.code,{children:"-like"})," wildcard to match only part of the message."]}),"\n",(0,t.jsxs)(s.li,{children:["Variables defined during Discovery, are not available in ",(0,t.jsx)(s.code,{children:"BeforeAll/-Each"}),", ",(0,t.jsx)(s.code,{children:"AfterAll/-Each"})," and ",(0,t.jsx)(s.code,{children:"It"}),". When generating tests via foreach blocks, make sure you pass all variables into the test using ",(0,t.jsx)(s.code,{children:"-ForEach"}),"."]}),"\n",(0,t.jsx)(s.li,{children:"Gherkin is removed, please keep using Pester version 4."}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"TestDrive"})," is defined during Run only, it cannot be used in ",(0,t.jsx)(s.code,{children:"-ForEach"}),"."]}),"\n"]}),"\n",(0,t.jsx)(s.h3,{id:"deprecated-features",children:"Deprecated features"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"Assert-MockCalled"})," is deprecated, it is recommended to use ",(0,t.jsx)(s.a,{href:"../usage/mocking",children:"Should -Invoke"}),"."]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"Assert-VerifiableMock"})," is deprecated, it is recommended to use ",(0,t.jsx)(s.a,{href:"../usage/mocking",children:"Should -InvokeVerifiable"}),"."]}),"\n",(0,t.jsxs)(s.li,{children:["Pending state (",(0,t.jsx)(s.code,{children:"Set-ItResult -Pending"}),") is deprecated and will be removed in a future version."]}),"\n"]}),"\n",(0,t.jsx)(s.h3,{id:"additional-issues-to-be-solved-future-releases",children:"Additional issues to be solved future releases"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.code,{children:"-Strict"})," switch is not available"]}),"\n",(0,t.jsx)(s.li,{children:"Automatic Code coverage via -CI switch currently disabled as it's slow. Can still be enabled using configuration, but is largely untested."}),"\n"]}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Noticed more of them? Share please!"})})]})}function h(e={}){let{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},7008(e,s,i){i.d(s,{R:()=>o,x:()=>a});var n=i(1763);let t={},r=n.createContext(t);function o(e){let s=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function a(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:o(e.components),n.createElement(r.Provider,{value:s},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.