Skip to content

This package wraps cypress-split and enables cypress parallelization for local docker

Notifications You must be signed in to change notification settings

TonyBrobston/cypress-split-local-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cypress-split-local-docker

This package wraps cypress-split and uses its Other CIs approach. This package grabs the current containers id and makes an api call to the docker api. It uses these two things to determine the current container's index and the number of containers running with the same service name as the current container. These two numbers are then passed to cypress-split.

Getting Started

Install this package (hopefully later this code will become a part of the cypress-split package, otherwise it may be published to npm; but for now, it needs installed from Github):

npm install -D git+ssh://[email protected]/TonyBrobston/cypress-split-local-docker.git

Update cypress.config.js:

const { defineConfig } = require('cypress');

module.exports = defineConfig({
  e2e: {
    async setupNodeEvents(on, config) {
      await require('cypress-split-local-docker')(on, config);
      return config;
    },
  },
});

Create/Update docker-compose.yml (replace http://localhost:3000 with your application's url):

version: "3.4"

services:
  cypress:
    image: cypress/included
    environment:
      - LOCAL=true
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - .:/home
    working_dir: /home
    entrypoint: /bin/bash -c 'npx wait-on@latest http://localhost:3000 && npx cypress run'

Run the cypress service and scale it:

docker-compose up --scale cypress=3

Other notes

It seems there is a small bug relating to querying containers, where the index ends up being greater than the count. It seems that docker container prune -f, which removes containers that are not running fixes the issue. I explicitly filter out all non-running containers, but I must be misunderstanding the data coming back from the docker api. This seems like a minor bug that is solvable, but I'm just using the workaround for now, since this project is proof of concept.

About

This package wraps cypress-split and enables cypress parallelization for local docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published