Problem:
One of my yeoman generator tests is failing during CI that is passing on my local dev machine.
Solution:
Clone the repo into a “generator-xxx” folder where xxx is the name of your generator instead of “s”.
Explanation:
By default, the build system clones all repos into a folder named “s”. This can cause problems when your tests are trying to load a sub generator.
You will get errors like the one below:
For the generators to be properly loaded the folder for your generator must be “generator-team” but when run on the build server it is “s”.
Luckily you are in complete control of your build using VSTS. To fix this issue I configured my build so that it would not clone my repo for me so I could do it myself and control the name.
Next I had to enable access to the OAuth Token on the Options tab.
Then I added a “Command Line” task to clone my repo. You must pass the access token using the %SYSTEM_ACCESSTOKEN% environment variable as part of your clone URL.
Then I simply adjusted the working directories of the remaining tasks in my build to target generator-team using $(Build.SourcesDirectory)/generator-team.