Reputation: 63
I am attempting to create a gitlab CI/CD pipeline that includes automated Cypress tests on a .NETcore project. I have a collection of cypress tests that I can successfully run locally. They are stored in the directory:
<project>/Cypress/integration/
My Gitlab CI/CD pipeline is successfully deploying and building the code on my testing server (Windows Server 2012). However, after deployment the cypress folder is not present on my testing server. However, when I build the project locally there is a cypress folder. In both my local build and the build defined by the gitlab-ci.yaml, the build command is the same:
dotnet publish -c Release
That said, during local builds, the content in my /bin/Release/netcoreapp2.1.publish/cypress does not include my locally created tests- just the examples provided by cypress. The restoring of the node packages is obviously creating a new cypress install.
How can I get my local cypress tests onto my testing server? Any why does the build done via Gitlab CI/CD and my local build differ in whether cypress gets installed?
I have tried updating my .csproj file to include the cypress directory in the build like so:
<ItemGroup>
<!-- include cypress tests in build for automated testing-->
<Content Include="cypress\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
But this gives me an error:
... error NETSDK1022: Duplicate 'Content' items were included...
Any suggestions on how to get this working? Below I am including my gitlab-ci.yaml file:
stages:
- build
- test
- deploy
build:
stage: build
tags:
- cris .netcore
script:
- echo "removing old files"
- 'Remove-Item -path D:\DeployedWebApps\cris-automated-tst\* -recurse'
- echo "dotnet build started"
- 'dotnet publish -c Release -o "D:\DeployedWebApps\cris-automated-tst\"'
test:
stage: test
tags:
- cris .netcore
script:
- echo "testing"
- 'npx cypress run'
deploy:
stage: deploy
tags:
- cris .netcore
script:
- echo "deploying"
when: on_success
environment:
name: Development
url: https://cris-automated-tst.gisdata.mn.gov
only:
- dev
Upvotes: 0
Views: 1289
Reputation: 63
Looks like I solved this on my own. The trick was to publish just the Cypress Integration folder rather than the whole Cypress directory:
<ItemGroup>
<!-- include cypress tests in build for automated testing-->
<Content Include="cypress\integration\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Upvotes: 1