From 4bb9108476e4ddeb75ac07a260c253bbb6312d7c Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 27 Jun 2022 15:23:50 -0700 Subject: [PATCH] Add end-to-end Pester unit test --- .vsts-ci/templates/ci-general.yml | 4 ++- .../DebugAdapterProtocolMessageTests.cs | 28 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index e252fcf403..bd474ab9ce 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -8,7 +8,9 @@ steps: displayName: PowerShell version inputs: targetType: inline - script: $PSVersionTable + script: | + $PSVersionTable + Get-Module -ListAvailable Pester pwsh: ${{ parameters.pwsh }} - task: UseDotNet@2 diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs index 14e2508237..800cff4789 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System; @@ -294,5 +294,31 @@ public async Task CanLaunchScriptWithCommentedLastLineAsync() Assert.Collection(GetLog(), (i) => Assert.Equal("a log statement", i)); } + + [Fact] + public async Task CanRunPesterTestFile() + { + string logStatement = GenerateScriptFromLoggingStatements("works"); + string filePath = NewTestFile(@" + Describe 'A' { + Context 'B' { + It 'C' { + throw 'error' + } + It 'D' { + " + logStatement + @" + } + } + } + "); + + await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(false); + + ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(false); + Assert.NotNull(configDoneResponse); + await Task.Delay(5000).ConfigureAwait(false); + + Assert.Collection(GetLog(), (i) => Assert.Equal("works", i)); + } } }