Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can cypress be made to work with aurelia with github actions and locally?

Ok, so I added cypress to aurelia during my configuration and it worked fine. When I went to set up cypress on github as just a command, I could not get it to recognize puppeteer as a browser. So instead I went and used the official github actions for cypress, and that works

      - name: test
        uses: cypress-io/github-action@v1
        with:
          start: yarn start
          browser: ${{matrix.browser}}
          record: true
        env:
          # pass the Dashboard record key as an environment variable
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

however I had to set my cypress.json as follows

{
  "baseUrl": "http://localhost:8080",
  "fixturesFolder": "test/e2e/fixtures",
  "integrationFolder": "test/e2e/integration",
  "pluginsFile": "test/e2e/plugins/index.js",
  "screenshotsFolder": "test/e2e/screenshots",
  "supportFile": "test/e2e/support/index.js",
  "videosFolder": "test/e2e/videos",
  "projectId": "..."
}

and now running yarn e2e doesn't work because there's no server stood up, as it's not doing it itself anymore via cypress.config.js

const CLIOptions =  require( 'aurelia-cli').CLIOptions;
const aureliaConfig = require('./aurelia_project/aurelia.json');
const PORT = CLIOptions.getFlagValue('port') || aureliaConfig.platform.port;
const HOST = CLIOptions.getFlagValue('host') || aureliaConfig.platform.host;

module.exports = {
  config: {
    baseUrl: `http://${HOST}:${PORT}`,
    fixturesFolder: 'test/e2e/fixtures',
    integrationFolder: 'test/e2e/integration',
    pluginsFile: 'test/e2e/plugins/index.js',
    screenshotsFolder: 'test/e2e/screenshots',
    supportFile: 'test/e2e/support/index.js',
    videosFolder: 'test/e2e/videos'
  }
};

how can I make it so that yarn e2e works as it previously did, and have it working on github?(I don't care which side of the equation is changed)

here's yarn e2e not sure what the au is doing under the hood.

    "e2e": "au cypress",
like image 551
xenoterracide Avatar asked Feb 10 '20 23:02

xenoterracide


People also ask

How to specify the E2e working directory for Cypress tests?

You can specify the e2e working directory when running Cypress tests using working-directory parameter Sometimes Cypress and end-to-end tests have their own package.json file in a subfolder, like In that case you can combine this action with bahmutov/npm-install action to install dependencies separately.

How to control the version of the action module in Cypress-Io?

When using cypress-io/github-action@v4 from your workflow file, you automatically will be using the latest tagged version from this repository. If you want to precisely control the version of this module, use the full tag version, for example: By using the full version tag, you will avoid accidentally using a newer version of the action.

How do I run a test in Cypress?

Run the browser in headed mode - as of Cypress v8.0 the cypress run command executes tests in headless mode by default You can run tests in a GH Action in your Docker container. 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.

What is the difference between GitHub actions and the Cypress dashboard?

The Cypress Dashboard offers the ability to parallelize and group test runs along with additional insights and analytics for Cypress tests. GitHub Actions offers a matrix strategy for declaring different job configurations for a single job definition.


Video Answer


1 Answers

Easiest way to achieve this, create a test/e2e/cypress-config.json

{
  "baseUrl": "http://localhost:8080",
  "fixturesFolder": "test/e2e/fixtures",
  "integrationFolder": "test/e2e/integration",
  "pluginsFile": "test/e2e/plugins/index.js",
  "screenshotsFolder": "test/e2e/screenshots",
  "supportFile": "test/e2e/support/index.js",
  "videosFolder": "test/e2e/videos",
  "projectId": "1234"
}

, and then setup the github action like this.

      - name: test
        uses: cypress-io/github-action@v1
        with:
          config-file: tests/e2e/cypress-config.json
          start: yarn start
          browser: ${{matrix.browser}}
          record: true
        env:
          # pass the Dashboard record key as an environment variable
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

the path doesn't matter, just that you configure the same one. Just make sure it doesn't overlap with what aurelia wants.

like image 82
xenoterracide Avatar answered Oct 31 '22 00:10

xenoterracide