【发布时间】:2020-09-02 01:00:07
【问题描述】:
我正在尝试使用 YAML 在 Azure Pipeline 作业中运行 cypress 测试。当管道运行时,它会到达 cypress 测试运行的行并抛出此错误:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\myagent\_work\5\s\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\myagent\_work\5\s\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
这是我的 YAML 文件:
trigger:
- master
pool:
name: Default
variables:
buildConfiguration: 'Release'
steps:
- task: NodeTool@0
displayName: 'Use Node 12.x'
inputs:
versionSpec: 12.18.3
checkLatest: false
- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: WebApp
verbose: false
- task: Npm@1
displayName: 'Build Angular'
inputs:
command: custom
customCommand: run build -- --prod
workingDir: WebApp
- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.1.300'
inputs:
packageType: sdk
version: 3.1.300
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: AppApi/AppApi.csproj
vstsFeed: '*************'
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: publish
arguments: '--no-restore --configuration $(buildConfiguration) --verbosity quiet --output $(build.artifactstagingdirectory)'
publishWebProjects: true
zipAfterPublish: true
- script: 'npx cypress verify'
displayName: 'cypress verify'
failOnStderr: true
- script: 'npm run cy:run --headless --spec cypress/integration/TestDemoExpanded.spec.ts --project ./WebApp'
displayName: 'run cypress tests'
workingDirectory: $(Build.SourcesDirectory)/WebApp
我的 package.json 已检入我的 Git 存储库并位于我的 WebApp 子文件夹中。如何解决此错误?
更新:
我按照建议添加了 workingDirectory 参数,但现在出现了这个新错误:npm ERR! missing script: cypress
我解决了“缺少脚本”错误。我在 YAML 文件中的 cypress run 命令与我在 package.json 中的 cypress run 命令不匹配。我更新了 cypress 运行步骤,现在测试在管道中运行。
【问题讨论】:
标签: azure-devops azure-pipelines cypress