# Pester test on Appveyor not importing my module

**URL:** <https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172>\
**Category:** PowerShell Help\
**Created:** [April 8, 2016, 11:59pm UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172 "2016-04-08T23:59:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![thesurlyadm1n](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/thesurlyadm1n/32/309_2.png) [@thesurlyadm1n](https://forums.powershell.org/u/thesurlyadm1n)\
**Post date:** [April 8, 2016, 11:59pm UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/1 "2016-04-08T23:59:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 9, 2016, 2:12am UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/2 "2016-04-09T02:12:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 9, 2016, 2:23am UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/3 "2016-04-09T02:23:36Z")

</div>

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

[https://github.com/martin9700/TestSQL/blob/master/TestSQL.psd1#L12](https://github.com/martin9700/TestSQL/blob/master/TestSQL.psd1#L12)

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: [https://github.com/martin9700/TestSQL/blob/master/Source/Test/Invoke-SQLQuery.tests.ps1#L3](https://github.com/martin9700/TestSQL/blob/master/Source/Test/Invoke-SQLQuery.tests.ps1#L3)

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.

---

<div class="post-metadata">

**Author:** ![thesurlyadm1n](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/thesurlyadm1n/32/309_2.png) [@thesurlyadm1n](https://forums.powershell.org/u/thesurlyadm1n)\
**Post date:** [April 9, 2016, 7:37am UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/4 "2016-04-09T07:37:55Z")

</div>

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.

> <https://gist.github.com/martin9700/f2aa2f4eb7e454b95a88421d428709d0>

---

<div class="post-metadata">

**Author:** ![thesurlyadm1n](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/thesurlyadm1n/32/309_2.png) [@thesurlyadm1n](https://forums.powershell.org/u/thesurlyadm1n)\
**Post date:** [April 9, 2016, 7:40am UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/5 "2016-04-09T07:40:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thesurlyadm1n](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/thesurlyadm1n/32/309_2.png) [@thesurlyadm1n](https://forums.powershell.org/u/thesurlyadm1n)\
**Post date:** [April 9, 2016, 9:36am UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/6 "2016-04-09T09:36:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thesurlyadm1n](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/thesurlyadm1n/32/309_2.png) [@thesurlyadm1n](https://forums.powershell.org/u/thesurlyadm1n)\
**Post date:** [April 10, 2016, 1:15am UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/7 "2016-04-10T01:15:59Z")

</div>

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?!

---

<div class="post-metadata">

**Author:** ![tombakerfl](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@tombakerfl](https://forums.powershell.org/u/tombakerfl)\
**Post date:** [April 10, 2016, 1:17pm UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/8 "2016-04-10T13:17:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thesurlyadm1n](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/thesurlyadm1n/32/309_2.png) [@thesurlyadm1n](https://forums.powershell.org/u/thesurlyadm1n)\
**Post date:** [April 10, 2016, 11:11pm UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/9 "2016-04-10T23:11:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:43pm UTC](https://forums.powershell.org/t/pester-test-on-appveyor-not-importing-my-module/6172/10 "2024-05-16T20:43:14Z")

</div>


