在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:cypress-io/github-action开源软件地址:https://github.com/cypress-io/github-action开源编程语言:JavaScript 96.9%开源软件介绍:cypress-io/github-action
Examples
Basicname: End-to-end tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v4 The workflow file .github/workflows/example-basic.yml shows how Cypress runs on GH Actions using Ubuntu (16, 18, or 20), on Windows, and on Mac without additional OS dependencies necessary. Note: this package assumes that Explicit versionBest practice: Our examples specify the tag of the action to use listing only the major version - name: Cypress run
uses: cypress-io/github-action@v4 When using - name: Cypress run
uses: cypress-io/[email protected] By using the full version tag, you will avoid accidentally using a newer version of the action. BrowserSpecify the browser name or path with name: E2E on Chrome
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
# let's make sure our tests pass on Chrome browser
name: E2E on Chrome
steps:
- uses: actions/checkout@v2
- uses: cypress-io/github-action@v4
with:
browser: chrome FirefoxIn order to run Firefox, you need to use non-root user (Firefox security restriction). name: Firefox
on: push
jobs:
firefox:
runs-on: ubuntu-latest
container:
image: cypress/browsers:node12.16.1-chrome80-ff73
options: --user 1001
steps:
- uses: actions/checkout@v2
- uses: cypress-io/github-action@v4
with:
browser: firefox Note: the magical user id Edgename: Edge
on: push
jobs:
tests:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: cypress-io/github-action@v4
with:
browser: edge Note: Microsoft has not released Edge for Linux yet, thus you need to run these tests on Windows or Mac runners with Edge preinstalled. You can use HeadedRun the browser in headed mode - as of Cypress v8.0 the name: Chrome headed
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: cypress-io/github-action@v4
with:
browser: chrome
headed: true Docker imageYou can run tests in a GH Action in your Docker container. name: E2E in custom container
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
# Cypress Docker image with Chrome v78
# and Firefox v70 pre-installed
container: cypress/browsers:node12.13.0-chrome78-ff70
steps:
- uses: actions/checkout@v2
- uses: cypress-io/github-action@v4
with:
browser: chrome EnvSpecify the env argument with name: Cypress tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run with env
uses: cypress-io/github-action@v4
with:
env: host=api.dev.local,port=4222 When passing the environment variables this way, unfortunately due to GitHub Actions syntax, the variables should be listed in a single line, which can be hard to read. As an alternative, you can use the step's name: Cypress tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run with env
uses: cypress-io/github-action@v4
env:
CYPRESS_host: api.dev.local
CYPRESS_port: 4222 For more examples, see the workflow example below. SpecsSpecify the spec files to run with name: Cypress tests
on: [push]
jobs:
cypress-run:
name: Cypress run
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v4
with:
spec: cypress/integration/spec1.js You can pass multiple multiple specs and wild card patterns using multi-line parameter, see example-config.yml: spec: |
cypress/integration/spec-a.js
cypress/**/*-b.js For more information, visit the Cypress command-line docs. ProjectSpecify the project to run with name: Cypress tests
on: [push]
jobs:
cypress-run:
name: Cypress run
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v4
with:
project: ./some/nested/folder For more information, visit the Cypress command-line docs. Record test results on Cypress Dashboardname: Cypress tests
on: [push]
jobs:
cypress-run:
name: Cypress run
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v4
with:
record: true
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Tip 1: We recommend using the action with Tip 2: we recommend passing the Tip 3: if running on Tip 4: to record the project needs name: Cypress tests
on: [push]
jobs:
cypress-run:
name: Cypress run
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v4
with:
record: true
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# pass the project ID from the secrets through environment variable
CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }} Quiet flagYou can provide name: example-quiet
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests with `quiet` parameter
- name: Cypress run
uses: ./
with:
working-directory: examples/quiet
quiet: true Tag recordingsYou can pass a single or multiple tags when recording a run. For example name: tags
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
# let's make sure our "app" works on several versions of Node
strategy:
matrix:
node: [10, 12]
name: E2E on Node v${{ matrix.node }}
steps:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: node -v
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v4
with:
record: true
tag: node-${{ matrix.node }}
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} The recording will have tags as labels on the run. You can pass multiple tags using commas like ArtifactsIf you don't record the test run on Cypress Dashboard, you can still store generated videos and screenshots as CI artifacts. See cypress-gh-action-example and the workflow example below name: Artifacts
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
name: Artifacts
steps:
- uses: actions/checkout@v2
- uses: cypress-io/github-action@v4
# after the test run completes
# store videos and any screenshots
# NOTE: screenshots will be generated only if E2E test failed
# thus we store screenshots only on failures
# Alternative: create and commit an empty cypress/screenshots folder
# to always have something to upload
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-videos
path: cypress/videos ConfigSpecify configuration values with name: Cypress tests
on: [push]
jobs:
cypress-run:
name: Cypress run
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v4
with:
config: pageLoadTimeout=100000,baseUrl=http://localhost:3000 Config FileSpecify the path to your config file with name: Cypress tests
on: [push]
jobs:
cypress-run:
name: Cypress run
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v4
with:
config-file: tests/cypress-config.json ParallelNote: Cypress parallelization requires Cypress Dashboard account. You can spin multiple containers running in parallel using name: Parallel Cypress Tests
on: [push]
jobs:
test:
name: Cypress run
runs-on: ubuntu-20.04
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run 3 copies of the current job in parallel
containers: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v2
# because of "record" and "parallel" parameters
# these containers will load balance all found tests among themselves
- name: Cypress run
uses: cypress-io/github-action@v4
with:
record: true
parallel: true
group: 'Actions example'
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Warning The Cypress GH Action does not spawn or create any additional containers - it only links the multiple containers spawned using the matrix strategy into a single logical Dashboard run and into splitting the specs amongst the machines. See the Cypress parallelization guide for the explanation. Component testsYou can run Cypress component tests in a job separate from E2E tests by adding 全部评论
专题导读
上一篇:platzi/platzigit: Curso Profesional de Git y GitHub发布时间:2022-06-11下一篇:exg/rxvt-unicode: git mirror of rxvt-unicode cvs repository发布时间:2022-06-11热门推荐
热门话题
阅读排行榜
|
请发表评论