FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 922 forks source link

[BUG] [web-test-runner-plugin] Test runner does not accept exclude options properly #2849

Open GeorgeTailor opened 3 years ago

GeorgeTailor commented 3 years ago

Bug Report Quick Checklist

Describe the bug

For some reason web-test-runner places files like myComponent.css.proxy.js in the final coverage report. But when trying to open that file I get the following error:

Unable to lookup source: /frontend/dist/common/IconCommon.css.proxy.js (ENOENT: no such file or directory, open '/frontend/dist/common/IconCommon.css.proxy.js')

One way to "fix" it is to add it to exclude options, but why such files are in the coverage report in the first place?

To Reproduce

We can't fix bugs that we can't see for ourselves. Issues often need to be closed if this section is skipped.

  1. npx create-snowpack-app snowpack-tests-sourcemap --template @snowpack/app-template-react-typescript
  2. add --coverage option to npm test in package.json
  3. run npm test
  4. open coverage html file and go to snowpack-tests-sourcemap/coverage/lcov-report/
  5. See that test.tsx files are included in the coverage report.

Expected behavior

Coverage report should not include test files themselves out of the box. When I've tried to exclude them manually via

exclude: [
    '**/*.test.js',
],

in my web-test-runner.config.js it does not work. What I needed to do is to add:

buildOptions: {
    sourcemap: true
}

to snowpack.config.js.

This is not documented anywhere and it should be provided by the plugin itself.

melissamcewen commented 3 years ago

Hi, I've attempted a replication here. I also could not get exclude to work but I also couldn't get it to work with the sourcemap options on or off. https://github.com/melissamcewen/snowpack-repros/tree/issue-2849/issue-2848

Let me know if I did something wrong.

Related: #2848

GeorgeTailor commented 3 years ago

I cannot find why it works in my project. In the project created with npx create-snowpack-app snowpack-tests-sourcemap --template @snowpack/app-template-react-typescript it does not work at all. I mean the exclude option does not work no matter what I do.