Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Instrumentation of micro frontends are not take into account #616

Open
jogelin opened this issue Feb 13, 2023 · 6 comments
Open

Code Instrumentation of micro frontends are not take into account #616

jogelin opened this issue Feb 13, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@jogelin
Copy link

jogelin commented Feb 13, 2023

Describe the bug
I have an application that follows the micro-frontends architecture. It means that some parts of the application are bundled separately and loaded in async mode.

I would like to see the code covered in my micro frontend. However, when debugging cypress coverage, I see the window.__coverage__ is undefined because the application is loaded but not the micro-frontend yet.

If debug and check the window.__coverage__ of the cypress iframe a bit later, it is filled correctly.

Is there a way to delay or restart the coverage configuration when we know that the page is ready? In our visit command per example?

Sequence

  1. Coverage correctly configured:
    image

  2. Visit the application page and load the main page:
    image

  3. Debug the beforeEach hook that is configuring the call to saveCoverageObject function when the window object is loaded:
    image
    image

  4. No instrumentation loaded (yet) because the micro-frontend is not yet loaded

  5. Load of the micro-frontend with the instrumentation

  6. Log the window.__coverage__ in the console ---> contains all paths

  7. Test successful!

Versions

"cypress": "12.5.1",
"@cypress/code-coverage": "^3.9.12",
❯ node -v
v18.13.0
❯ node -v
v18.13.0

Configs

Instrumentation of the code using babel-plugin-istanbul:

module: {
      rules: [
        {
          test: /\.(js|ts)$/,
          loader: 'babel-loader',
          options: { plugins: ['babel-plugin-istanbul'] },
          enforce: 'post',
          include: [...],
          exclude: [...],
        },
      ],
    },

nyc.config.js:

module.exports = (projectRoot) => ({
  extends: '@istanbuljs/nyc-config-typescript',
  'report-dir': require('path').resolve(__dirname, `dist/cypress/${projectRoot}/reports/coverage`),
  reporter: ['json'],
  extensions: ['.ts'],
  cwd: __dirname,
  exclude: [
    '**/node_modules/**',
    '**/test/**',
    '**/.storybook/**',
    '**/cypress/**',
    '**/cypress-legacy/**',
    '**/generated/**',
    '**/*.d.ts',
    '**/*.mdx',
    '**/*stories*.{js,ts}',
    '**/*spec*.{js,ts}',
    '**/*.cy*.{js,ts}',
    '**/index.{js,ts}',
    '**/jest.config.{js,ts}',
    '**/*.interface*.{js,ts}',
    '**/*.type*.{js,ts}',
    '**/*webpack*.config.{js,ts}',
    '**/.{eslint,mocha}rc.{js,cjs}',
    '**/*-e2e/**/*.*',
    '**/*main.{js,ts}',
    '**/*set-public-path.{js,ts}',
  ],
  excludeAfterRemap: true,
  all: true,
  sourceMap: false,
  instrument: false,
});

DEBUG

  code-coverage combined NYC options { 'report-dir': '/Users/################/app-name-e2e/reports/coverage', reporter: [ 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, extends: '@istanbuljs/nyc-config-typescript', extensions: [ '.ts' ], cwd: '################', exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], all: true, sourceMap: false, instrument: false } +0ms

  code-coverage reset code coverage in interactive mode +0ms

⚠️ file /Users/################/apps/app-name-e2e/.nyc_output/out.json has no coverage information
Did you forget to instrument your web application? Read https://github.com/cypress-io/code-coverage#instrument-your-application

  code-coverage ⚠️ file /Users/################/apps/app-name-e2e/.nyc_output/out.json has no coverage information +10m
  code-coverage ⚠️ file /Users/################/apps/smc/app-name-e2e/.nyc_output/out.json has no coverage information +2ms
  code-coverage nyc needs to report on all included files +8s
  code-coverage include all files options: { all: true, include: undefined, exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ] } +3ms
  code-coverage using default list of extensions +10ms
  code-coverage searching files to include using patterns [ '**/*.js', '**/*.cjs', '**/*.mjs', '**/*.ts', '**/*.tsx', '**/*.jsx', '!**/node_modules/**', '!**/test/**', '!**/.storybook/**', '!**/cypress/**', '!**/cypress-legacy/**', '!**/generated/**', '!**/*.d.ts', '!**/*.mdx', '!**/*stories*.{js,ts}', '!**/*spec*.{js,ts}', '!**/*.cy*.{js,ts}', '!**/index.{js,ts}', '!**/jest.config.{js,ts}', '!**/*.interface*.{js,ts}', '!**/*.type*.{js,ts}', '!**/*webpack*.config.{js,ts}', '!**/.{eslint,mocha}rc.{js,cjs}', '!**/*-e2e/**/*.*', '!**/*main.{js,ts}', '!**/*set-public-path.{js,ts}', '!**/shared-ng/ui/**', '!**/shared/ui/**', '!**/node_modules/**' ] +0ms

  code-coverage found 0 file(s) +146ms
  code-coverage no files found, hoping for the best +1ms
  code-coverage calling NYC reporter with options { 'report-dir': '/Users/################dist/cypress/apps/app-name-e2e/reports/coverage', reporter: [ 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, extends: '@istanbuljs/nyc-config-typescript', extensions: [ '.ts' ], cwd: '/Users/Jgelin/dev/grizzly', exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], all: true, sourceMap: false, instrument: false, 'temp-dir': '/Users/################/apps/app-name-e2e/.nyc_output', tempDir: '/Users/################/apps/app-name-e2e/.nyc_output', reportDir: '/Users/################/dist/cypress/apps/app-name-e2e/reports/coverage' } +160ms
  code-coverage current working directory is /Users/################/apps/app-name-e2e +1ms
  code-coverage after reporting, returning the report folder name /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage +332ms
  code-coverage Final coverage in /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage/coverage-final.json +1ms
  code-coverage There are 0 key(s) in /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage/coverage-final.json +2ms
@jogelin
Copy link
Author

jogelin commented Feb 13, 2023

Just initializing the window.__coverage__ in my visit command solves the issue.

In fact, the reference of the object is kept by cypress

@winjay-yu-awx
Copy link

Just initializing the window.__coverage__ in my visit command solves the issue.

In fact, the reference of the object is kept by cypress

Thanks @jogelin, it fixed my issue.

@Atul78
Copy link

Atul78 commented Aug 28, 2023

Describe the bug I have an application that follows the micro-frontends architecture. It means that some parts of the application are bundled separately and loaded in async mode.

I would like to see the code covered in my micro frontend. However, when debugging cypress coverage, I see the window.__coverage__ is undefined because the application is loaded but not the micro-frontend yet.

If debug and check the window.__coverage__ of the cypress iframe a bit later, it is filled correctly.

Is there a way to delay or restart the coverage configuration when we know that the page is ready? In our visit command per example?

Sequence

  1. Coverage correctly configured:
    image
  2. Visit the application page and load the main page:
    image
  3. Debug the beforeEach hook that is configuring the call to saveCoverageObject function when the window object is loaded:
    image
    image
  4. No instrumentation loaded (yet) because the micro-frontend is not yet loaded
  5. Load of the micro-frontend with the instrumentation
  6. Log the window.__coverage__ in the console ---> contains all paths
  7. Test successful!

Versions

"cypress": "12.5.1",
"@cypress/code-coverage": "^3.9.12",
❯ node -v
v18.13.0
❯ node -v
v18.13.0

Configs

Instrumentation of the code using babel-plugin-istanbul:

module: {
      rules: [
        {
          test: /\.(js|ts)$/,
          loader: 'babel-loader',
          options: { plugins: ['babel-plugin-istanbul'] },
          enforce: 'post',
          include: [...],
          exclude: [...],
        },
      ],
    },

nyc.config.js:

module.exports = (projectRoot) => ({
  extends: '@istanbuljs/nyc-config-typescript',
  'report-dir': require('path').resolve(__dirname, `dist/cypress/${projectRoot}/reports/coverage`),
  reporter: ['json'],
  extensions: ['.ts'],
  cwd: __dirname,
  exclude: [
    '**/node_modules/**',
    '**/test/**',
    '**/.storybook/**',
    '**/cypress/**',
    '**/cypress-legacy/**',
    '**/generated/**',
    '**/*.d.ts',
    '**/*.mdx',
    '**/*stories*.{js,ts}',
    '**/*spec*.{js,ts}',
    '**/*.cy*.{js,ts}',
    '**/index.{js,ts}',
    '**/jest.config.{js,ts}',
    '**/*.interface*.{js,ts}',
    '**/*.type*.{js,ts}',
    '**/*webpack*.config.{js,ts}',
    '**/.{eslint,mocha}rc.{js,cjs}',
    '**/*-e2e/**/*.*',
    '**/*main.{js,ts}',
    '**/*set-public-path.{js,ts}',
  ],
  excludeAfterRemap: true,
  all: true,
  sourceMap: false,
  instrument: false,
});

DEBUG

  code-coverage combined NYC options { 'report-dir': '/Users/################/app-name-e2e/reports/coverage', reporter: [ 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, extends: '@istanbuljs/nyc-config-typescript', extensions: [ '.ts' ], cwd: '################', exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], all: true, sourceMap: false, instrument: false } +0ms

  code-coverage reset code coverage in interactive mode +0ms

⚠️ file /Users/################/apps/app-name-e2e/.nyc_output/out.json has no coverage information
Did you forget to instrument your web application? Read https://github.com/cypress-io/code-coverage#instrument-your-application

  code-coverage ⚠️ file /Users/################/apps/app-name-e2e/.nyc_output/out.json has no coverage information +10m
  code-coverage ⚠️ file /Users/################/apps/smc/app-name-e2e/.nyc_output/out.json has no coverage information +2ms
  code-coverage nyc needs to report on all included files +8s
  code-coverage include all files options: { all: true, include: undefined, exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ] } +3ms
  code-coverage using default list of extensions +10ms
  code-coverage searching files to include using patterns [ '**/*.js', '**/*.cjs', '**/*.mjs', '**/*.ts', '**/*.tsx', '**/*.jsx', '!**/node_modules/**', '!**/test/**', '!**/.storybook/**', '!**/cypress/**', '!**/cypress-legacy/**', '!**/generated/**', '!**/*.d.ts', '!**/*.mdx', '!**/*stories*.{js,ts}', '!**/*spec*.{js,ts}', '!**/*.cy*.{js,ts}', '!**/index.{js,ts}', '!**/jest.config.{js,ts}', '!**/*.interface*.{js,ts}', '!**/*.type*.{js,ts}', '!**/*webpack*.config.{js,ts}', '!**/.{eslint,mocha}rc.{js,cjs}', '!**/*-e2e/**/*.*', '!**/*main.{js,ts}', '!**/*set-public-path.{js,ts}', '!**/shared-ng/ui/**', '!**/shared/ui/**', '!**/node_modules/**' ] +0ms

  code-coverage found 0 file(s) +146ms
  code-coverage no files found, hoping for the best +1ms
  code-coverage calling NYC reporter with options { 'report-dir': '/Users/################dist/cypress/apps/app-name-e2e/reports/coverage', reporter: [ 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, extends: '@istanbuljs/nyc-config-typescript', extensions: [ '.ts' ], cwd: '/Users/Jgelin/dev/grizzly', exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], all: true, sourceMap: false, instrument: false, 'temp-dir': '/Users/################/apps/app-name-e2e/.nyc_output', tempDir: '/Users/################/apps/app-name-e2e/.nyc_output', reportDir: '/Users/################/dist/cypress/apps/app-name-e2e/reports/coverage' } +160ms
  code-coverage current working directory is /Users/################/apps/app-name-e2e +1ms
  code-coverage after reporting, returning the report folder name /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage +332ms
  code-coverage Final coverage in /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage/coverage-final.json +1ms
  code-coverage There are 0 key(s) in /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage/coverage-final.json +2ms

How did you instrument your code? It will be helpfull if you provide me some context regarding instrumentation of the code to generage the code-coverage.

@lukastipcak
Copy link

Just initializing the window.__coverage__ in my visit command solves the issue.

In fact, the reference of the object is kept by cypress

Can you please provide an example? How did you initialize the window.__coverage__ in visit command? Thx

@PushpendraKatoria
Copy link

Describe the bug I have an application that follows the micro-frontends architecture. It means that some parts of the application are bundled separately and loaded in async mode.

I would like to see the code covered in my micro frontend. However, when debugging cypress coverage, I see the window.__coverage__ is undefined because the application is loaded but not the micro-frontend yet.

If debug and check the window.__coverage__ of the cypress iframe a bit later, it is filled correctly.

Is there a way to delay or restart the coverage configuration when we know that the page is ready? In our visit command per example?

Sequence

  1. Coverage correctly configured:
    image
  2. Visit the application page and load the main page:
    image
  3. Debug the beforeEach hook that is configuring the call to saveCoverageObject function when the window object is loaded:
    image
    image
  4. No instrumentation loaded (yet) because the micro-frontend is not yet loaded
  5. Load of the micro-frontend with the instrumentation
  6. Log the window.__coverage__ in the console ---> contains all paths
  7. Test successful!

Versions

"cypress": "12.5.1",
"@cypress/code-coverage": "^3.9.12",
❯ node -v
v18.13.0
❯ node -v
v18.13.0

Configs

Instrumentation of the code using babel-plugin-istanbul:

module: {
      rules: [
        {
          test: /\.(js|ts)$/,
          loader: 'babel-loader',
          options: { plugins: ['babel-plugin-istanbul'] },
          enforce: 'post',
          include: [...],
          exclude: [...],
        },
      ],
    },

nyc.config.js:

module.exports = (projectRoot) => ({
  extends: '@istanbuljs/nyc-config-typescript',
  'report-dir': require('path').resolve(__dirname, `dist/cypress/${projectRoot}/reports/coverage`),
  reporter: ['json'],
  extensions: ['.ts'],
  cwd: __dirname,
  exclude: [
    '**/node_modules/**',
    '**/test/**',
    '**/.storybook/**',
    '**/cypress/**',
    '**/cypress-legacy/**',
    '**/generated/**',
    '**/*.d.ts',
    '**/*.mdx',
    '**/*stories*.{js,ts}',
    '**/*spec*.{js,ts}',
    '**/*.cy*.{js,ts}',
    '**/index.{js,ts}',
    '**/jest.config.{js,ts}',
    '**/*.interface*.{js,ts}',
    '**/*.type*.{js,ts}',
    '**/*webpack*.config.{js,ts}',
    '**/.{eslint,mocha}rc.{js,cjs}',
    '**/*-e2e/**/*.*',
    '**/*main.{js,ts}',
    '**/*set-public-path.{js,ts}',
  ],
  excludeAfterRemap: true,
  all: true,
  sourceMap: false,
  instrument: false,
});

DEBUG

  code-coverage combined NYC options { 'report-dir': '/Users/################/app-name-e2e/reports/coverage', reporter: [ 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, extends: '@istanbuljs/nyc-config-typescript', extensions: [ '.ts' ], cwd: '################', exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], all: true, sourceMap: false, instrument: false } +0ms

  code-coverage reset code coverage in interactive mode +0ms

⚠️ file /Users/################/apps/app-name-e2e/.nyc_output/out.json has no coverage information
Did you forget to instrument your web application? Read https://github.com/cypress-io/code-coverage#instrument-your-application

  code-coverage ⚠️ file /Users/################/apps/app-name-e2e/.nyc_output/out.json has no coverage information +10m
  code-coverage ⚠️ file /Users/################/apps/smc/app-name-e2e/.nyc_output/out.json has no coverage information +2ms
  code-coverage nyc needs to report on all included files +8s
  code-coverage include all files options: { all: true, include: undefined, exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ] } +3ms
  code-coverage using default list of extensions +10ms
  code-coverage searching files to include using patterns [ '**/*.js', '**/*.cjs', '**/*.mjs', '**/*.ts', '**/*.tsx', '**/*.jsx', '!**/node_modules/**', '!**/test/**', '!**/.storybook/**', '!**/cypress/**', '!**/cypress-legacy/**', '!**/generated/**', '!**/*.d.ts', '!**/*.mdx', '!**/*stories*.{js,ts}', '!**/*spec*.{js,ts}', '!**/*.cy*.{js,ts}', '!**/index.{js,ts}', '!**/jest.config.{js,ts}', '!**/*.interface*.{js,ts}', '!**/*.type*.{js,ts}', '!**/*webpack*.config.{js,ts}', '!**/.{eslint,mocha}rc.{js,cjs}', '!**/*-e2e/**/*.*', '!**/*main.{js,ts}', '!**/*set-public-path.{js,ts}', '!**/shared-ng/ui/**', '!**/shared/ui/**', '!**/node_modules/**' ] +0ms

  code-coverage found 0 file(s) +146ms
  code-coverage no files found, hoping for the best +1ms
  code-coverage calling NYC reporter with options { 'report-dir': '/Users/################dist/cypress/apps/app-name-e2e/reports/coverage', reporter: [ 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, extends: '@istanbuljs/nyc-config-typescript', extensions: [ '.ts' ], cwd: '/Users/Jgelin/dev/grizzly', exclude: [ '**/node_modules/**', '**/test/**', '**/.storybook/**', '**/cypress/**', '**/cypress-legacy/**', '**/generated/**', '**/*.d.ts', '**/*.mdx', '**/*stories*.{js,ts}', '**/*spec*.{js,ts}', '**/*.cy*.{js,ts}', '**/index.{js,ts}', '**/jest.config.{js,ts}', '**/*.interface*.{js,ts}', '**/*.type*.{js,ts}', '**/*webpack*.config.{js,ts}', '**/.{eslint,mocha}rc.{js,cjs}', '**/*-e2e/**/*.*', '**/*main.{js,ts}', '**/*set-public-path.{js,ts}', '**/shared-ng/ui/**', '**/shared/ui/**' ], all: true, sourceMap: false, instrument: false, 'temp-dir': '/Users/################/apps/app-name-e2e/.nyc_output', tempDir: '/Users/################/apps/app-name-e2e/.nyc_output', reportDir: '/Users/################/dist/cypress/apps/app-name-e2e/reports/coverage' } +160ms
  code-coverage current working directory is /Users/################/apps/app-name-e2e +1ms
  code-coverage after reporting, returning the report folder name /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage +332ms
  code-coverage Final coverage in /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage/coverage-final.json +1ms
  code-coverage There are 0 key(s) in /Users/################/dist/cypress/apps/app-name-e2e/reports/coverage/coverage-final.json +2ms

How did you instrument your microfrontend code? Can you please share the repo or example? I need help in instrumenting my micfrontend application for cypress code coverage but not able to figure out the way

@jennifer-shehane jennifer-shehane added the bug Something isn't working label Jan 5, 2024
@josephKearns
Copy link

josephKearns commented May 22, 2024

+1
We also experience this issue using MFE architecture. The symptoms are the same. The workaround of setting the window.__coverage__ is the same. Currently I have this in place for our first visit to the root app before the MFE are loaded:

cy.visit("/", {
      onBeforeLoad(win: Cypress.AUTWindow) {
        const sourceCoverage = Object.keys(win).includes("__coverage__");
        if (!sourceCoverage) {
          Object.defineProperty(win, "__coverage__", {
            value: {},
            writable: true,
            enumerable: true,
            configurable: true,
          });
        }
      },
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants