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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage is only collected from javascript files #9490

Closed
raimund-schluessler opened this issue Jan 31, 2020 · 6 comments
Closed

Coverage is only collected from javascript files #9490

raimund-schluessler opened this issue Jan 31, 2020 · 6 comments

Comments

@raimund-schluessler
Copy link

raimund-schluessler commented Jan 31, 2020

馃挜 Regression Report

Coverage data is only collected from javascript files, but not from e.g. vue files, although configured to collect data from vue files as well.

Last working version

Worked up to version: 24.9.0

Stopped working in version: 25.1.0

To Reproduce

Steps to reproduce the behavior:

Have a repository with js and vue files and configure jest to report coverage for both file types using this configuration:

"jest": {
	"moduleFileExtensions": [
		"js",
		"vue"
	],
	"moduleNameMapper": {
		"^@/(.*)$": "<rootDir>/src/$1"
	},
	"testEnvironment": "jest-environment-jsdom-sixteen",
	"transform": {
		"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
		".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
	},
	"snapshotSerializers": [
		"<rootDir>/node_modules/jest-serializer-vue"
	],
	"setupFilesAfterEnv": [
		"./tests/javascript/unit/setup.js"
	],
	"coverageDirectory": "./coverage/",
	"collectCoverage": true,
	"collectCoverageFrom": [
		"<rootDir>/src/**/*.{js,vue}",
		"!**/node_modules/**"
	],
	"coverageReporters": [
		"json",
		"text",
		"html",
		"lcov",
		"clover"
	]
},

Run jest and see that coverage is only reported for js files. The problem might be related to #9464.

Expected behavior

Coverage should be reported for js and vue files.

Link to repl or repo (highly encouraged)

The repository is https://github.com/nextcloud/tasks. If a minimal example is preferred I can provide one as well.

Run npx envinfo --preset jest

npx: Installierte 1 in 1.749s

  System:
    OS: Linux 4.9 Debian GNU/Linux 9 (stretch) 9 (stretch)
    CPU: (2) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  Binaries:
    Node: 13.7.0 - /usr/local/bin/node
    npm: 6.13.6 - /usr/local/bin/npm
  npmPackages:
    jest: ^25.1.0 => 25.1.0 

@aldarund
Copy link
Contributor

aldarund commented Feb 3, 2020

Can confirm, jest 25.1 stopped to collect coverage from vue files. 24.9 is fine.

@Ignigena
Copy link

Same here. Downgrading to Jest 24 fixes the issue and .vue files show coverage. Using similar config as the OP that explicitly enables coverage collection for the extension:

module.exports = {
  collectCoverage: true,
  collectCoverageFrom: [
    '**/*.{js,vue}',
    [...]

@Fandyx
Copy link

Fandyx commented Feb 14, 2020

I'm facing the same issue, but if I try to downgrade to 24 my tests fails

Test suite failed to run

.../node_modules/@babel/runtime-corejs2/helpers/esm/defineProperty.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _Object$defineProperty from "../../core-js/object/define-property";
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^

    SyntaxError: Unexpected identifier

The solution posted here works fine for me:
vuejs/vue-jest#217 (comment)

joelmukuthu added a commit to joelmukuthu/svelte-typescript-jest-webpack that referenced this issue Mar 21, 2020
Had to downgrade jest to v24. Coverage is broken for non-js files in
v2: jestjs/jest#9490
@raimund-schluessler
Copy link
Author

The update to Jest 25.2.4 (possibly earlier already) seems to have fixed the issue. With nextcloud/tasks@5dd7179 I see the coverage being reported for vue files again.

joelmukuthu added a commit to joelmukuthu/svelte-typescript-jest-webpack that referenced this issue Mar 31, 2020
Seems to have fixed the coverage issue.
Ref: jestjs/jest#9490 (comment)
@raimund-schluessler
Copy link
Author

I close this since the issue is fixed with 25.2.4..

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants