azure 如何以特定顺序运行测试- Playwright YAML文件

13z8s7eq  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(108)

我在为我的剧作家测试创建一个Azure管道时卡住了。我希望测试按特定顺序进行。
这就是我的YAML文件现在的样子,但现在它只是以不正确的顺序运行所有测试。

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '18'
  displayName: 'Install Node.js'

- script: npm ci
  displayName: 'npm ci'

- script: npx playwright install --with-deps
  displayName: 'Install Playwright browsers'

- script: npx playwright test
  displayName: 'Run Playwright tests'

- task: PublishTestResults@2
  displayName: 'Publish test results'
  inputs:
    searchFolder: 'test-results'
    testResultsFormat: 'JUnit'
    testResultsFiles: 'e2e-junit-results.xml'
    mergeTestResults: true
    failTaskOnFailedTests: true
    testRunTitle: 'My End-To-End Tests'
  condition: succeededOrFailed()
  
- task: PublishPipelineArtifact@1
  inputs:
    targetPath: playwright-report
    artifact: playwright-report
    publishLocation: 'pipeline'
  condition: succeededOrFailed()

字符串
这是我的结构。例如,我想先运行createTraveler.spec.ts,然后再运行createSingleTrip
我试过写作

- script: |
    npx jest ./Digor.Web/playwright-tests/createTraveler.spec.ts
  displayName: 'Run createTraveler.spec.ts'

- script: |
    npx jest ./Digor.Web/playwright-tests/createSingleTrip.spec.ts
  displayName: 'Run createSingleTrip.spec.ts'


但似乎不起作用。

qzlgjiam

qzlgjiam1#

我克隆了this存储库,并尝试以特定顺序运行测试文件。

  • 我的Azure克隆存储库:-*

x1c 0d1x的数据

  • 我尝试在ContactUsTest.spec. ts之前运行CreateAccountTest. spec.ts,它成功运行,代码如下:-*
    我的Yaml代码:-
trigger:
  - main

pool:
  vmImage: ubuntu-latest

steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '18'
    displayName: 'Install Node.js'

  - script: npm ci
    displayName: 'npm ci'

  - script: npx playwright install --with-deps
    displayName: 'Install Playwright browsers'

  
  - script: npx playwright test src/tests/files/CreateAccountTest.spec.ts
    displayName: 'Run CreateAccountTest.spec.ts'

 
  - script: npx playwright show-report test-results/results
    displayName: 'Show test report'
    
  
  - script: npx playwright test src/tests/files/ContactUsTest.spec.ts
    displayName: 'Run ContactUsTest.spec.ts'

  
  - script: npx playwright show-report test-results/results
    displayName: 'Show test report'

字符串



您可以参考此link,通过指定过滤器以不同的顺序运行npx playwright命令。

  • 运行文件名为my-spec和my-spec-2的npx命令
npx playwright test my-spec my-spec-2

  • 特定项目的运行测试
npx playwright test  --project=chromium

相关问题