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 coverage e2e and unit test combining not working #265

Open
julianklumpers opened this issue Jun 20, 2020 · 5 comments
Open

Code coverage e2e and unit test combining not working #265

julianklumpers opened this issue Jun 20, 2020 · 5 comments

Comments

@julianklumpers
Copy link

julianklumpers commented Jun 20, 2020

Logs and screenshots

first.spec.ts
Screenshot 2020-06-20 at 23 44 58

second.spec.ts
Screenshot 2020-06-20 at 23 43 12

Versions

  • What is this plugin's version? If this is NOT the latest released version can you try the latest version, please?
    3.8.1

  • If the plugin worked before in version X, but stopped after upgrading to version Y, please try the released versions between X and Y to see where the breaking change was.

  • What is Cypress version?
    4.8.0

  • What is your operating system?
    macos

  • What is the shell?
    zsh

  • What is the Node version?
    10.17.0

  • What is the NPM version?
    6.11.3

  • How do you instrument your application? Cypress does not instrument web application code, so you need to do it yourself.
    With CRA custom override
    webpackConfig.module.rules[2].oneOf[1].options.plugins.push('babel-plugin-istanbul')

  • When running tests, if you open the web application in regular browser, and open DevTools, do you see window.__coverage__ object? Can you paste a screenshot?
    Screenshot 2020-06-20 at 23 51 37

  • Is there .nyc_output folder? Is there .nyc_output/out.json file. Is it empty? Can you paste at least part of it so we can see the keys and file paths?
    Screenshot 2020-06-20 at 23 57 10

  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files
    no

  • Do you run Cypress tests in a Docker container?
    no
    Describe the bug
    I instrumented my code via the guide on the cypress site. coverage for the e2e tests are working but not for the separate unit tests as shown in the videos. it says it cannot find __coverage__.

i use typescript in my project and test files.

Link to the repo
Bugs with a reproducible example, like an open source repo showing the bug, are the most likely to be resolved.

Example
See #217 that is an excellent bug report example

@edimitchel
Copy link

Hi @julianklumpers, You still have this issue ?

@pakatagoh
Copy link

pakatagoh commented Aug 27, 2020

I'm getting a similar issue when working with spec files that have unit tests

Placing the following into cypress/plugins/index.js according to the docs returns me an error message shown as below

/// <reference types="cypress" />

module.exports = (on, config) => {
  require('@cypress/code-coverage/task')(on, config);
  on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'));
  return config;
};

image

Currently working on a Next.js project in a monorepo

.babelrc

{
  "presets": ["next/babel"],
  "plugins": [
    [
      "styled-components",
      {
        "ssr": true,
        "displayName": true,
        "preprocess": false
      }
    ],
    "istanbul"
  ],
}

Installed @istanbuljs/nyc-config-typescript cypress nyc source-map-support ts-node

Inside package.json

  "nyc": {
    "extends": "@istanbuljs/nyc-config-typescript"
  },

After changing /cypress/plugins/index.js to the following

const browserify = require('@cypress/browserify-preprocessor');
le.exports = (on, config) => {
  require('@cypress/code-coverage/task')(on, config);

  const options = browserify.defaultOptions;
  options.browserifyOptions.transform[1][1].babelrc = true;
  on('file:preprocessor', browserify({ ...options, typescript: require.resolve('typescript') }));
  return config;
};

I get a new error
image

Any help or insights will be appreciated. After looking through the examples, there doesn't seem to be one with a cypress(cypress tests written in ts as well) + monorepo(not sure if this would affect anything) + Next.js(written with ts)

@jashworth
Copy link

Hi @pakatagoh, did you manage to find a fix?

@pakatagoh
Copy link

Hi @pakatagoh, did you manage to find a fix?

@jashworth unfortunately not. it's been a year since I've worked on the issue. in the end I believe we falled back to many more unit tests. sorry I don't have a solution.

@jashworth
Copy link

@pakatagoh Thanks for replying.

I managed to get it working with webpack in the end, in a similar way to #435, where I've added a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants