quasar-testing icon indicating copy to clipboard operation
quasar-testing copied to clipboard

#227: Webpack code coverage support

Open gtrombitas opened this issue 3 years ago • 6 comments

What kind of change does this PR introduce? (check at least one)

  • [ ] Bugfix
  • [ ] New test runner
  • [ ] Documentation
  • [x] Feature
  • [ ] Code style update
  • [ ] Refactor
  • [ ] Build-related changes
  • [ ] Other, please describe:

If you are adding a new test runner, have you...? (check all)

  • [ ] Created an issue first?
  • [ ] Registered it in /packages/base/runners.json?
  • [ ] Added it to /README.md?
  • [ ] Included one test that runs baseline.spec.vue?
  • [ ] Added and updated documentation?
  • [ ] Included a recipe folder with properly building quasar project?

Does this PR introduce a breaking change? (check one)

  • [ ] Yes
  • [x] No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • [x] It's submitted to the dev branch and not the master branch
  • [x] When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • [x] It's been tested on Windows
  • [ ] It's been tested on Linux
  • [x] It's been tested on MacOS
  • [ ] Any necessary documentation has been added or updated in the docs (for faster update click on "Suggest an edit on GitHub" at bottom of page) or explained in the PR's description.

If adding a new feature, the PR's description includes:

  • The modification introduces Webpack support for e2e-cypress package.

Other information:

add @cypress/code-coverage according to this link (babel-plugin-istanbul isn't needed here because it's bundled with coverage-istanbul-loader.

add "code-coverage" option to quasar.extensions.json

"@quasar/testing-e2e-cypress": {
    "options": [
      "scripts",
      "typescript",
      "code-coverage"
    ]
  }

add nyc settings in the end of package.json

"nyc": {
    "temp-dir": "temp/.nyc_output",
    "include": [
      "src/**"
    ],
    "extension": [
      ".js",
      ".ts",
      ".vue"
    ],
    "report-dir": "test/cypress/coverage"
  }

execute sync:cypress npm script in test-project-webpack project

gtrombitas avatar Jul 07 '22 16:07 gtrombitas

Thanks for the contribution :) I don't have time to test it right now, but I left some comments on what seems to be off at a first glance

IlCallo avatar Jul 07 '22 16:07 IlCallo

@IlCallo I fixed the requested changes please check them.

gtrombitas avatar Jul 08 '22 09:07 gtrombitas

hi @gtrombitas, and thanks for the PR, I have run some tests on it. Coverage of .ts files is perfect, but .vue files seem to have some issues, it seems all files are getting the exact same coverage, with the same uncovered block position (see screens).

image image

maiolica avatar Jul 15 '22 07:07 maiolica

@maiolica Thank you for the review and testing effort. Unfortunately I couldn't find any other solutions to handle .vue file instrumentation better. I opened an issue to coverage-istanbul-loader library: link Hopefully they can advise a concrete solution or a workaround for this problem.

gtrombitas avatar Jul 19 '22 10:07 gtrombitas

I'm regularly checking that issue, but the project seems abandoned since 2020 The whole Instanbul ecosystem seems freezed in time right now

Is there any reliable alternative into JS ecosystem?

IlCallo avatar Nov 29 '22 10:11 IlCallo

Thanks for the sync-up. Yes, I have seen the same thing at Istanbul repo. Unfortunately I'm not familiar with any other alternatives to this library. When I have a little time for it then I'll try to look into some other libs. If something already exists at all...

gtrombitas avatar Nov 29 '22 10:11 gtrombitas