bahmutov / cypress-split-example

Split Cypress specs on GitHub Actions
https://github.com/bahmutov/cypress-split
10 stars 8 forks source link

Error: Do not know how to determine the correct split using AWS CodeBuild #69

Open aksyuma opened 7 months ago

aksyuma commented 7 months ago

Research Done:

Using your existing GitLab CI example, I have tried to mimic this in AWS CodeBuild project as follows:

Created CodeBuild buildspec file:

Using reference from cypress-realworld-app:

version: 0.2

batch:
  fast-fail: false
  build-matrix:
    dynamic:
      env:
        compute-type:
          - BUILD_GENERAL1_MEDIUM
          WORKERS:
            - 1
            - 2

phases:
  install:
    commands:
      - yarn install --frozen-lockfile
  build:
    commands:
      - npx @bahmutov/print-env CI_
      - npx cypress run --env split=true

Updated Cypress.config.ts as follows:

import { defineConfig } from 'cypress';
import cypressSplit from 'cypress-split'

export default defineConfig({

  e2e: {
    baseUrl: 'http://localhost:3000',
    specPattern: 'cypress/e2e/**/*.cy.ts',
    testIsolation: true,
    setupNodeEvents(on, config) {
      cypressSplit(on, config)
      // IMPORTANT: return the config object
      return config
    },
  },

Error after executed Cypress headless mode:

Error: Do not know how to determine the correct split
--
676 | at cypressSplit (/codebuild/output/src/src/git-codecommit.us-east-1.amazonaws.com/v1/repos/cypress-split-gitlab-example/node_modules/cypress-split/src/index.js:78:13)
677 | at setupNodeEvents (file:///codebuild/output/src/src/git-codecommit.us-east-1.amazonaws.com/v1/repos/cypress-split-gitlab-example/cypress.config.ts:10:13)
678 | at /root/.cache/Cypress/13.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:122:14
679 | at tryCatcher (/root/.cache/Cypress/13.3.1/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
680 | at Promise.attempt.Promise.try (/root/.cache/Cypress/13.3.1/Cypress/resources/app/node_modules/bluebird/js/release/method.js:39:29)
681 | at RunPlugins.load (/root/.cache/Cypress/13.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:119:9)
682 | at RunPlugins.runSetupNodeEvents (/root/.cache/Cypress/13.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:59:17)
683 | at EventEmitter.<anonymous> (/root/.cache/Cypress/13.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:185:22)
684 | at EventEmitter.emit (node:events:514:28)
685 | at process.<anonymous> (/root/.cache/Cypress/13.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
686 | at process.emit (node:events:514:28)
687 | at emit (node:internal/child_process:951:14)
688 | at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

Question:

Q1. How to use this package with AWS Codebuild? Q2. In .gitlab-ci.yml there is flag parallel: 3 being used! Where to place this flag in AWS CodeBuild buildspec file?