Pester test on Appveyor not importing my module

Putting together my first appveyor/pester test for a module and failing miserably. Integration is all working, but when I do an Import-Module in my pester test it simply doesn’t import the functions. It says it is but nothing gets imported. I’ve tried Get-Command -Module TestSQL after the import.

Anyone seen anything like this? Not sure what information I can provide but happy to post the pester scripts/yml if needed.

Will need to see the code, not sure what’s going on based on your description so far.

Found it on GitHub. :slight_smile: Two things jumped out at me:

You’ve got RootModule = ‘TestSQL’ ; this might need to say ‘TestSQL.psm1’. I’ve never tried it without an extension before.

In your Tests.ps1 file, you’re using an absolute path for the import:

Personally, I would always use a relative path here:

Import-Module "$PSScriptRoot\..\..\TestSQL.psd1"

But since your appveyor job seems to be set up to clone to the same absolute path that’s mentioned in the Tests.ps1 script, that may be fine.

Hi Dave, I’ve always done just the Folder name there. I should note that this all works fine on my PC, so it’s definitely a appveyor thing. I do have explicit paths in there right now as I’m just getting this off the ground for now, but I have big plans (bwahahaha)

Anyway, the module looks like it’s loading, but when I do Get-Command -Module TestSQL I get nothing (see below). G1, G2 and G3 are all locators where I do the Get-Command right after.

That said, will give it a try. Syncing now, and build is queued. Have to run out to dinner (argh!) so I’ll update later tonight on pass/fail.

Just an update. Same problem as above. Module looks like it loads, but then none of the functions are there.

Wanted to leave a last update. Loading the module using just the folder name still fails. Funny enough, this happened before when RootModule didn’t have the name of the folder in it on an earlier version of my module creation script.

That data is there now and still won’t load in appveyor, however, I did get the functions to load if I specified the PSM1 extension. I suspect some kind of issue with the manifest file, but it works fine on a regular PC (hah, on “my” PC, famous last words) and this seems to be simply an Appveyor problem.

So, now I have to get SQL properly configured so the module can be tested. Why did I pick this as my first Appveyor project?!

Try changing functions to export in your manifest to an array of strings rather than one big string.

Hey Tom, I thought I had fixed that! Was using a hashtable and the .Keys property but it’s interested how New-ModuleManifest and Update-ModuleManifest treat that differently! I originally had something else in mind which is why I used a hashtable in this instance but that requirement went away so I think I’ll just switch over to an Array.List instead and that should resolve that problem.