donal
2018-03-21 1a68cfa5d296372bd33dcff4574efa9cec5b925c
WIP - getting jest coverage to work
2 files added
8 files modified
3916 ■■■■■ changed files
.gitignore 1 ●●●● patch | view | raw | blame | history
jest.config.js 29 ●●●●● patch | view | raw | blame | history
package-lock.json 3809 ●●●●● patch | view | raw | blame | history
package.json 21 ●●●● patch | view | raw | blame | history
package.json.bak 41 ●●●●● patch | view | raw | blame | history
public/index.html 4 ●●●● patch | view | raw | blame | history
public/manifest.json 4 ●●●● patch | view | raw | blame | history
src/components/HelloWorld.vue 2 ●●● patch | view | raw | blame | history
tests/unit/.eslintrc 2 ●●● patch | view | raw | blame | history
tests/unit/HelloWorld.spec.js 3 ●●●● patch | view | raw | blame | history
.gitignore
@@ -22,3 +22,4 @@
*.ntvs*
*.njsproj
*.sln
test-report.xml
jest.config.js
New file
@@ -0,0 +1,29 @@
module.exports = {
  moduleFileExtensions: [
    "js",
    "jsx",
    "json",
    "vue"
  ],
  transform: {
    "^.+\\.vue$": "vue-jest",
    "^.+\\.jsx?$": "babel-jest"
  },
  moduleNameMapper: {
    "^@/(.*)$": "<rootDir>/src/$1"
  },
  snapshotSerializers: ["jest-serializer-vue"],
  collectCoverage: true,
  collectCoverageFrom: [
    "src/**/*.{js,vue}",
    "!src/**/*.test.{js,jsx}",
    "!<rootDir>/node_modules/"
  ],
  testResultsProcessor: './node_modules/jest-junit-reporter',
  coverageDirectory: './reports/coverage',
  coverageReporters: [
    "text",
    "html",
    "clover"
  ]
}
package-lock.json
Diff too large
package.json
@@ -1,16 +1,13 @@
{
  "name": "cli-test",
  "name": "cli-test2",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "./node_modules/.bin/vue-cli-service serve --open",
    "build": "./node_modules/.bin/vue-cli-service build",
    "test": "./node_modules/.bin/vue-cli-service test",
    "e2e": "./node_modules/.bin/vue-cli-service e2e",
    "e2e-ci": "./node_modules/.bin/vue-cli-service e2e --env jenkins --url http://localhost:8080",
    "lint": "./node_modules/.bin/vue-cli-service lint",
    "e2e-setup": "./node_modules/.bin/selenium-standalone install",
    "e2e-ci-old": "npm run e2e-setup && ./node_modules/.bin/nightwatch --config nightwatch.config.js --env jenkins"
    "serve": "vue-cli-service serve --open",
    "build": "vue-cli-service build",
    "test": "vue-cli-service test",
    "e2e": "vue-cli-service e2e",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "register-service-worker": "^1.0.0",
@@ -23,11 +20,13 @@
    "@vue/cli-plugin-e2e-nightwatch": "^3.0.0-beta.6",
    "@vue/cli-plugin-eslint": "^3.0.0-beta.6",
    "@vue/cli-plugin-pwa": "^3.0.0-beta.6",
    "@vue/cli-plugin-unit-mocha": "^3.0.0-beta.6",
    "@vue/cli-plugin-unit-jest": "^3.0.0-beta.6",
    "@vue/cli-service": "^3.0.0-beta.6",
    "@vue/eslint-config-prettier": "^3.0.0-beta.6",
    "@vue/test-utils": "^1.0.0-beta.10",
    "chai": "^4.1.2",
    "babel-core": "^7.0.0-0",
    "babel-jest": "^22.0.4",
    "jest-junit-reporter": "^1.1.0",
    "node-sass": "^4.7.2",
    "sass-loader": "^6.0.6",
    "vue-template-compiler": "^2.5.13"
package.json.bak
New file
@@ -0,0 +1,41 @@
{
  "name": "cli-test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "./node_modules/.bin/vue-cli-service serve --open",
    "build": "./node_modules/.bin/vue-cli-service build",
    "test": "./node_modules/.bin/vue-cli-service test",
    "e2e": "./node_modules/.bin/vue-cli-service e2e",
    "e2e-ci": "./node_modules/.bin/vue-cli-service e2e --env jenkins --url http://localhost:8080",
    "lint": "./node_modules/.bin/vue-cli-service lint",
    "e2e-setup": "./node_modules/.bin/selenium-standalone install",
    "e2e-ci-old": "npm run e2e-setup && ./node_modules/.bin/nightwatch --config nightwatch.config.js --env jenkins"
  },
  "dependencies": {
    "register-service-worker": "^1.0.0",
    "vue": "^2.5.13",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-beta.6",
    "@vue/cli-plugin-e2e-nightwatch": "^3.0.0-beta.6",
    "@vue/cli-plugin-eslint": "^3.0.0-beta.6",
    "@vue/cli-plugin-pwa": "^3.0.0-beta.6",
    "@vue/cli-plugin-unit-jest": "^3.0.0-beta.6",
    "@vue/cli-service": "^3.0.0-beta.6",
    "@vue/eslint-config-prettier": "^3.0.0-beta.6",
    "@vue/test-utils": "^1.0.0-beta.10",
    "babel-core": "^7.0.0-0",
    "babel-jest": "^22.0.4",
    "node-sass": "^4.7.2",
    "sass-loader": "^6.0.6",
    "vue-template-compiler": "^2.5.13"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}
public/index.html
@@ -5,11 +5,11 @@
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="shortcut icon" href="<%= webpackConfig.output.publicPath %>favicon.ico">
    <title>cli-test</title>
    <title>cli-test2</title>
  </head>
  <body>
    <noscript>
      <strong>We're sorry but cli-test doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
      <strong>We're sorry but cli-test2 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
public/manifest.json
@@ -1,6 +1,6 @@
{
  "name": "cli-test",
  "short_name": "cli-test",
  "name": "cli-test2",
  "short_name": "cli-test2",
  "icons": [
    {
      "src": "/img/icons/android-chrome-192x192.png",
src/components/HelloWorld.vue
@@ -11,7 +11,7 @@
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank">babel</a></li>
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa" target="_blank">pwa</a></li>
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank">eslint</a></li>
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-unit-mocha" target="_blank">unit-mocha</a></li>
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-unit-jest" target="_blank">unit-jest</a></li>
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-e2e-nightwatch" target="_blank">e2e-nightwatch</a></li>
    </ul>
    <h3>Essential Links</h3>
tests/unit/.eslintrc
@@ -1,6 +1,6 @@
{
  "env": {
    "mocha": true
    "jest": true
  },
  "rules": {
    "import/no-extraneous-dependencies": "off"
tests/unit/HelloWorld.spec.js
@@ -1,4 +1,3 @@
import { expect } from "chai";
import { shallow } from "@vue/test-utils";
import HelloWorld from "@/components/HelloWorld.vue";
@@ -8,6 +7,6 @@
    const wrapper = shallow(HelloWorld, {
      propsData: { msg }
    });
    expect(wrapper.text()).to.include(msg);
    expect(wrapper.text()).toMatch(msg);
  });
});