LambdaTest / lambdatest-cypress-cli

Allows Customers to run cypress test on Lambdatest Infrastructure
https://www.lambdatest.com/
MIT License
7 stars 24 forks source link

Lambdatest-Cypress-CLI and Github Actions #145

Closed le-anne closed 1 year ago

le-anne commented 2 years ago

Context

I'm attempting to run the lambdatest-cypress-cli through Github Actions on every code push.

Issue

When attempting to run lambdatest-cypress-cli on Github Actions, it fails during the LambdaTest Cypress Run step due to not having the spec file present.

Code

I changed my record keys, tokens, etc. to generic names for the sake of this post.

#Workflow Name
name: Trigger browser testing

#Trigger
on:
  #manually-evoked from Github Actions tab/CLI
  workflow_dispatch:
    #interactive inputs
    inputs:
      versioname:
        description: "Version:"
        required: true
        default: ""

#Actions
jobs:
  Deploy_live_test:
    name: Live test deploy
    runs-on: ubuntu-latest
    steps:

      - name: LambdaTest Cypress CLI Test
        shell: bash
        run: npm install -g lambdatest-cypress-cli

      - name: LambdaTest Tunnel Action
        uses: LambdaTest/LambdaTest-tunnel-action@v1
        id: tunnel-id
        with:
          user: "username"
          accessKey: "accesskey"
          tunnelName: "tunnelname"

      - 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@v2
        with:
          record: true
        env:
          # pass the Dashboard record key as an environment variable
          CYPRESS_RECORD_KEY: "cypressrecordkey"
          # pass GitHub token to allow accurately detecting a build vs a re-run build
          GITHUB_TOKEN: "githubtoken"
          # pass the project ID from the secrets through environment variable
          CYPRESS_PROJECT_ID: "cypressproject"

      - name: LambdaTest Cypress Run
        shell: bash
        run: export LT_USERNAME="LT_name" && export LT_ACCESS_KEY="LT_key" && lambdatest-cypress init && lambdatest-cypress run --cy="--cypress-record-key "cypressrecordkey"" --username "username" --key "key"

Here is my folder structure, spec highlighted: folder

Any help would be appreciated. Thank you!

japneetlambdatest commented 2 years ago

Hey @le-anne , I see lambdatest-cypress init has to be done only once. Most of the options are self-explanatory but you can use the following doc for a more clean view https://www.lambdatest.com/support/docs/running-your-first-cypress-test. You can mention the spec files in the config file and then this should work

Doing an init every time will recreate the lambdatest config file every time and all your saved configurations will be lost

japneetlambdatest commented 1 year ago

Closing due to unactivity