code-coverage icon indicating copy to clipboard operation
code-coverage copied to clipboard

Support collection of code coverage from multiple services

Open lihaibh opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. It is currently possible to fetch code coverage report from the browser (the frontend code) as well as backend. However, you can configure only 1 endpoint and if your application is composed of multiple services, we need to be able to extract code coverage from them as well.

Describe the solution you'd like I want to configure cypress in such a way that it will collect code coverage from multiple endpoints, and remove expectBackendCoverageOnly which i think is redundant for example:

codeCoverage: {
      collectFrontendCoverage: true,
      services: [
        {
          url: `${
            process.env.cypress_baseUrl || 'http://localhost:9001'
          }/__coverage__`,
          remotePath: `/backend`,
          localPath: `${process.cwd()}/backend`,
        },
        {
          url: `http://localhost:9002/__coverage__`,
          remotePath: `/app`,
          localPath: `${process.cwd()}/service2`,
        },
      ],
    },

In order to provide backward compatability, still use the url property, and by default search for coverage from window.originUrl/__coverage__ remotePath and localPath are optional. We need this in case we are running our services on a remote machine / docker container and the paths are not synced with our local sources path.

Describe alternatives you've considered You can basically create a service that doing the collection for you from all the other services, but its not a good approach. Additionally, instead of remotePath and localPath you can create a middleware on your service that perform the mapping of the local source path, to what it should be in the docker host, but again it is not a good approach.

lihaibh avatar Oct 18 '22 14:10 lihaibh