3

I installed the Powershell Tools for Visual Studio 2015 then I created a tests.ps1 files inside my Powershell project in VS2015. the test explorer recognizes the declared test, but when I try to run the test I get this: "Result Message: Failed to load Pester module. The specified module 'Pester' was not loaded because no valid module file was found in any module directory."

VS2015

I discover that I did not have the Pester in my Pc, I download it from GitHub, then I add the folder to the $env:PSModulePath. Powershell identifies the module, but was not able to import it, so I move the folder from its original location to: c:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\ Now any console of powershell is able to import the module: ISE, Powershell console, Powershell interactive window in VS2015.

Then I try to run the test again, I keep getting the same message.

XtianGIS
  • 967
  • 16
  • 39

1 Answers1

2

As I stated in my question: I added the folder with the Pester to the environment variable called PSModulePath, but I added to the end of it.

For some reason the adaptor looks for the path of module only under the first folder in that environment variable.

I changed the order and moved the path to the beginning of the string. Voila!! it works.

James Wiseman
  • 29,946
  • 17
  • 95
  • 158
XtianGIS
  • 967
  • 16
  • 39
  • I log off, then I log in again, the change in the environment variable take place after this action. – XtianGIS Apr 12 '16 at 21:42
  • Of course, an alternative approach would have been to place the module under the first folder specified under the environment variable. This would have removed any need to log off. – James Wiseman Nov 28 '16 at 16:48