title: Get code coverage from Cypress with babel, nyc and istanbul plugin?
body: <p>For a React/Redux project I use Cypress to test the UI. I need to get code coverage from thoses tests to have the details in Sonar (but that's another story).</p>
  
  <p>So I began reading the docs from Cypress: <a href="https://docs.cypress.io/guides/tooling/code-coverage.html" rel="nofollow noreferrer">https://docs.cypress.io/guides/tooling/code-coverage.html</a></p>
  
  <p>I followed the instructions and found the differents plugins but nothing work. After running Cypress tests I have no coverage results and when I try to run the server with instrumented code on transpilation and try to get <code>window.__coverage__</code> it's <code>undefined</code>.</p>
  
  <p>So here is my configuration.</p>
  
  <p>My devDep and NYC conf in <em>package.json</em>:</p>
  
  <pre><code>"devDependencies": {
      "@cypress/code-coverage": "^1.8.0",
      "babel-cli": "^6.26.0",
      "babel-plugin-istanbul": "^5.2.0",
      "babel-plugin-react-intl": "^2.4.0",
      "babel-plugin-transform-class-properties": "^6.24.1",
      "babel-preset-react-app": "^3.1.2",
      "cross-env": "^5.2.0",
      "cypress": "3.1.0",
      "istanbul-lib-coverage": "^2.0.5",
      "jest-junit-reporter": "^1.1.0",
      "junit": "^1.4.9",
      "nyc": "^14.1.1",
      "react-test-renderer": "^16.3.0"
       [...]
  },
  "scripts": {
      "start": "react-scripts start",
      [...]
      "test:unit:local": "react-scripts test --env=jsdom .*_test.js",
      "test:unit": "npm run test:unit:local -- --ci --coverage --testResultsProcessor ./node_modules/jest-junit-reporter",
      "test:integ:local": "cypress run --reporter junit",
      "test:integ": "start-server-and-test start http://localhost:3000 test:integ:local",
      "test": "cross-env NODE_ENV=test &amp;&amp; npm run test:unit &amp;&amp; npm run test:integ"
  },
  "nyc": {
      "sourceMap": false,
      "instrument": false
  }
  </code></pre>
  
  <p>My <code>.babelrc</code> file:</p>
  
  <pre><code>{
  "presets": ["@babel/preset-react"],
  "plugins": [
      [ "react-intl", {
          "messagesDir": "./src/messages",
          "extractSourceLocation": true
      }],
      "transform-class-properties",
      "istanbul"
  ],
  "env": {
      "test": {
        "plugins": [ "transform-class-properties", "istanbul" ]
      }
    }
  }
  </code></pre>
  
  <p>My <code>\cypress\support\index.js</code> contains this line :</p>
  
  <p><code>import '@cypress/code-coverage/support'</code></p>
  
  <p>And here is my <code>\cypress\plugins\index.js</code>:</p>
  
  <pre><code>module.exports = (on, config) =&gt; {
      on('task', require('@cypress/code-coverage/task'))
      on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'))
      return config
  }
  </code></pre>
  
  <p>So I expect to have a result like you can see on the Cypress docs.
  The website is generated but the files containing coverage reports are empty.</p>
  
  <p>And I don't understand what's wrong in my configuration.</p>