I am using “jest”: “^20.0.4” & “babel-jest”: “^23.6.0” packages for running unti test cases for in my Vue 2 project. Node 10.2.0v.
While running npm run test coverage is zero. It’s failed to collect coverage from file.
my Package dependencies
"dependencies": {
"@vue/test-utils": "^1.0.0-beta.29",
"animejs": "^3.2.0",
"axios": "^0.16.2",
"bootstrap-sass": "3.3.7",
"envify": "^4.1.0",
"es6-promise": "^4.1.1",
"hammerjs": "^2.0.8",
"javascript-time-ago": "^2.0.6",
"jest-junit": "^6.0.1",
"jest-localstorage-mock": "^2.4.0",
"jest-serializer-vue": "^2.0.2",
"jquery": "^3.1.1",
"jquery-validation": "^1.16.0",
"jquery-validation-unobtrusive": "^3.2.6",
"key-sitecore-vue-plugin": "^1.0.2",
"lazysizes": "^3.0.0-rc3",
"lodash": "^4.17.4",
"natives": "^1.1.6",
"node-sass": "^4.11.0",
"owl.carousel": "^2.2.0",
"require-dir": "^1.2.0",
"swiper": "^5.0.1",
"vue": "^2.5.16",
"vue-check-view": "^0.3.0",
"vue-computed-helpers": "^1.3.0",
"vue-cookie": "^1.1.4",
"vue-cookies": "^1.5.6",
"vue-flatpickr-component": "^8.1.0",
"vue-good-table": "^2.3.0",
"vue-highlight-text": "^1.6.2",
"vue-jest": "^3.0.1",
"vue-js-modal": "^1.3.12",
"vue-js-toggle-button": "^1.2.2",
"vue-modal": "^1.0.2",
"vue-modal-dialogs": "^2.0.0",
"vue-modals": "^0.5.0",
"vue-modaltor": "^1.2.4",
"vue-moment": "^3.2.0",
"vue-paginate": "^3.6.0",
"vue-popup": "^0.2.14",
"vue-range-slider": "^0.6.0",
"vue-resource": "^1.5.1",
"vue-scrollto": "^2.13.0",
"vue-server-renderer": "^2.4.2",
"vue-shave": "^1.0.3",
"vue-slider-component": "^2.6.1",
"vue-star-rating": "^1.5.1",
"vue-swal": "^0.1.0",
"vue-switches": "^2.0.1",
"vue-test-utils": "^1.0.0-beta.11",
"vue-update": "^1.0.6",
"vue-words-highlight": "^1.1.2",
"vue-ya-semantic-elements": "0.0.4",
"vue-ya-semantic-modal": "0.0.3",
"vue-youtube": "^1.4.0",
"vuejs-datepicker": "^1.5.4",
"vuejs-paginator": "^2.0.2",
"vuetable": "^1.5.12",
"vuex": "^2.4.0",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"@frctl/fractal": "^1.0.11",
"autoprefixer": "^6.5.4",
"babel-core": "^6.26.3",
"babel-jest": "^23.6.0",
"babel-loader": "^8.1.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-polyfill": "^6.20.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.18.0",
"babelify": "^7.3.0",
"browserify": "^13.1.1",
"browserify-shim": "^3.8.12",
"eslint": "^3.12.1",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "^6.8.0",
"eslint-plugin-vue": "^4.7.1",
"event-stream": "^3.3.4",
"exorcist": "^0.4.0",
"fs": "0.0.1-security",
"glob": "^7.1.1",
"globby": "^6.1.0",
"gulp": "^3.9.1",
"gulp-clean-css": "^2.3.2",
"gulp-concat": "^2.6.1",
"gulp-cached": "^1.1.1",
"gulp-copy": "^1.0.0",
"gulp-environments": "^0.1.1",
"gulp-exec": "^2.1.3",
"gulp-eslint": "^6.0.0",
"gulp-filter": "^5.0.0",
"gulp-imagemin": "7.1.0",
"gulp-load-plugins": "^1.4.0",
"gulp-modify-css-urls": "^0.2.2",
"gulp-nuget-restore": "^0.4.0",
"gulp-postcss": "^6.2.0",
"gulp-replace": "^0.5.4",
"gulp-sass": "^3.0.0",
"gulp-sourcemaps": "^1.9.1",
"gulp-svg-sprite": "^1.3.6",
"gulp-uglify": "^2.0.0",
"gulp-uglify-es": "^3.0.0",
"gulp-watch": "^5.0.1",
"inchjs": "^0.4.1",
"jasmine": "^2.5.2",
"jasmine-core": "^2.5.2",
"jasmine-reporters": "^2.3.2",
"jest": "^20.0.4",
"jest-serializer-html": "^4.0.1",
"jest-vue-preprocessor": "^1.4.0",
"jquery-match-height": "^0.7.0",
"jsdoc": "^3.4.3",
"jsdoc-vue": "^1.0.0",
"mocha": "^3.2.0",
"run-sequence": "^1.2.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"vinyl-transform": "^1.0.0",
"vueify": "^9.4.0",
"watchify": "^3.8.0"
},
.babelrc
{
"presets": ["es2015"],
"plugins": ["transform-object-assign"],
"presets": ["env"]
}
jest.config.json
{
"testMatch": [ "**/**/*.spec.js" ],
"collectCoverageFrom": [
"src/**/*.js",
"src/**/*.vue",
"!src/**/plugins/**/*.js",
"!src/**/plugins/**/*.vue",
"!src/**/Plugins/**/*.js",
"!src/**/Plugins/**/*.vue",
"!<rootDir>/node_modules/",
"!<rootDir>/packages/"
],
"moduleFileExtensions": [
"js",
"vue"
],
"moduleNameMapper": {
"^vue$": "vue/dist/vue.common.js"
},
"moduleDirectories": ["node_modules", "./src/Foundation/"],
"setupFiles": [
"<rootDir>/tasks/jest/polyfill.request-animation-frame.js",
"<rootDir>/tasks/jest/polyfill.matchMedia.js",
"<rootDir>/tasks/jest/setup.eventBus.js",
"<rootDir>/tasks/jest/setup.stub.js",
"<rootDir>/tasks/jest/setup.geolocation.js",
"jest-localstorage-mock"
],
"verbose": true,
"setupTestFrameworkScriptFile": "./setup-jasmine-env.js",
"snapshotSerializers": [
"jest-serializer-vue"
],
"unmockedModulePathPatterns": [
"./node_modules/jasmine-reporters"
],
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 0,
"lines": 0,
"statements": 0
}
},
"transform": {
"^.+\.js$": "<rootDir>/node_modules/babel-jest",
".*\.(vue)$": "<rootDir>/node_modules/vue-jest"
},
"reporters": ["default", ["jest-junit", { "output": "coverage/junit.xml" }]],
"coverageReporters": ["text", "lcov", "cobertura"]
}
Test suite failed to run
TypeError [ERR_INVALID_ARG_TYPE]: The “from” argument must be of type string. Received type undefined
getting this Error:
ERROR: TypeError [ERR_INVALID_ARG_TYPE]: The “from” argument must be of type string. Received type undefined
STACK: TypeError [ERR_INVALID_ARG_TYPE]: The “from” argument must be of type string. Received type undefined
Any idea about this error.
I have updated jest latest version for this. It was not supporting my node version.