question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Monorepo with multiple apps usage - allow passing of `projects` array to `cypress run`

See original GitHub issue

Say I have a monorepo with multiple apps which share libs. If i modify a shared lib and want to test if my apps pass the tests, what is the best approach?

- packages
	- app-1
		- cypress
	- app-2
		- cypress
	- shared-library-1
	- shared-library-2
  • Can I have cypress search for multiple integrationFolders so that a single test run will test all my apps?
  • Maybe I could use a cypress dir in the monorepo root, then have symlinks to the different cypress/integration folders in each app in the monorepo?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

15reactions
sharmilajesupaulcommented, Mar 16, 2020

@vjpr @jennifer-shehane This isn’t complete workaround because it won’t handle the case where tests have different support files, fixtures, or different configurations in cypress.json.

Can we re-open this issue?

We also use a monorepo at Airbnb, that looks something like:

projects/
  --  projectA
      -- cypress.json
      -- cypress
          -- integration
          -- support
          -- fixtures
              -- user.json

  --  projectB
      -- cypress.json
      -- cypress
          -- integration
          -- support
          -- fixtures
              -- user.json

You can symlink all the integration tests but that will still break on any test with its own fixture files or custom commands in the support directory. We also use mutually exclusive support commands, some teams choose to convert fetch to XHR, while others don’t.

Right now, we invoke Cypress multiple times for a project in CI, and this comes with unexpected problems, eg. xvfb exitting non-zero (that could be fixed by https://github.com/cypress-io/cypress-docker-images/issues/54#issuecomment-487060555).


It would be great if cypress run + open supported projects by allowing you to pass in multiple directories that contained their own cypress.json files – this is similar to Jest’s projects:

See: https://jestjs.io/docs/en/configuration#projects-arraystring--projectconfig

projects [array<string | ProjectConfig>] Default: undefined When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified projects at the same time. This is great for monorepos or when working on multiple projects at the same time.

That way, in the root cypress.json we could specify the projects that we want to invoke cypress for like this:

{
  "defaultUrl": "https://www.airbnb.com",
  "projects": ["projects/projectA", "projects/projectB"],
}

And then when invoking cypress at the root of a monorepo, we can run all projects, or pick specific ones by using a flag to override the config like: --projects frontend/projectA.

2reactions
jennifer-shehanecommented, Mar 19, 2020

Right now, we invoke Cypress multiple times for a project in CI, and this comes with unexpected problems, eg. xvfb exitting non-zero (that could be fixed by cypress-io/cypress-docker-images#54 (comment)).

@sharmilajesupaul I would make sure to express your issue in the https://github.com/cypress-io/cypress-docker-images/issues/54 issue, as commenting / expressing how this is a blocker definitely helps when prioritizing which things we work on.

Passing a projects flag is not a bad idea. It will not be as simple to implement as expected though. I will reopen this issue with the intent being to allow running multiple projects from a single cypress run command, but this would not be very high priority for us at the moment unfortunately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Utilizing Cypress Testing in a Multi-App Monorepo
Getting it set up for an app is pretty straightforward, and you can be off and writing tests in a matter of minutes....
Read more >
Running Cypress tests in a monorepo - Jonathan Creamer
Cypress is a fantastic testing tool for running your applications in a browser like environment. It's reminiscent of Selenium, but runs quicker ...
Read more >
Drastically Simplify Testing on CI with Cypress GitHub Action
Here is an example GH Action workflow that splits entire test load across 3 machines using strategy > matrix > machines: [1, 2,...
Read more >
A Complete Guide to Running a Full-Stack Angular ...
The monorepo strategy follows the approach (as in the following image) where we can have multiple projects in a single repository. This strategy ......
Read more >
@cypress/github-action - npm
Start using @cypress/github-action in your project by running `npm i ... Use specific config file; Run tests in parallel; Build app before running...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found