Skip to content

Instantly share code, notes, and snippets.

@nothingismagick
Last active May 29, 2018 14:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nothingismagick/6f62c12ffd8583d1419c6be172996b44 to your computer and use it in GitHub Desktop.
Save nothingismagick/6f62c12ffd8583d1419c6be172996b44 to your computer and use it in GitHub Desktop.
Installing JEST on Quasar 0.16
npm install --save-dev jest vue-jest vue-test-loader regenerator-runtime babel-jest 'babel-core@7.0.0-bridge.0'

Add the following to your package.json

package.json

  "scripts": {
    "jest": "jest",
    "jest:cover": "jest --coverage",
  },
  "jest": {
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/utils/*.js" // depends on project
    ],
    "transformIgnorePatterns": [
      "node_modules/core-js",
      "node_modules/babel-runtime"
    ],
    "moduleNameMapper": {
      "quasar": "quasar-framework/dist/quasar.mat.esm.js"
    }
  }

Then you can just "yarn run jest"

{
"env": {
"test": {
"presets": [ [
"@babel/preset-env", {
"modules": "commonjs",
"node": "current"
}
]
]
}
},
"presets": [
[
"@babel/preset-env", {
"modules": false,
"loose": false,
"useBuiltIns": "usage"
}
],
[
"@babel/preset-stage-2", {
"modules": false,
"loose": false,
"useBuiltIns": true,
"decoratorsLegacy": true
}
]
],
"plugins": [
[
"@babel/transform-runtime", {
"polyfill": false,
"regenerator": false
}
]
],
"comments": false
}
import foo from './thing.js';
test('foo bar', () => {
expect(foo()).toBe('bar');
});
export default function foo() {
return 'bar';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment