Skip to content

Commit 926f67e

Browse files
authored
Merge pull request #41 from dnohashi/save
Merging Quasar - Jest test suite
2 parents f4ad370 + 0ffd549 commit 926f67e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+21684
-5560
lines changed

.babelrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"plugins": ["@babel/plugin-syntax-dynamic-import"],
3+
"env": {
4+
"test": {
5+
"plugins": ["dynamic-import-node"],
6+
"presets": [
7+
[
8+
"@babel/preset-env",
9+
{
10+
"modules": "commonjs",
11+
"targets": {
12+
"node": "current"
13+
}
14+
}
15+
]
16+
]
17+
}
18+
}
19+
}

babel.config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
const fs = require('fs-extra')
2+
let extend = undefined
3+
4+
/**
5+
* The .babelrc file has been created to assist Jest for transpiling.
6+
* You should keep your application's babel rules in this file.
7+
*/
8+
9+
if (fs.existsSync('./.babelrc')) {
10+
extend = './.babelrc'
11+
}
12+
113
module.exports = {
214
presets: [
315
'@quasar/babel-preset-app'
4-
]
16+
],
17+
extends: extend
518
}

jest.config.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
module.exports = {
2+
globals: {
3+
__DEV__: true
4+
},
5+
setupFilesAfterEnv: [
6+
'<rootDir>/test/jest/jest.setup.js'
7+
],
8+
// noStackTrace: true,
9+
// bail: true,
10+
// cache: false,
11+
// verbose: true,
12+
// watch: true,
13+
collectCoverage: true,
14+
coverageDirectory: '<rootDir>/test/jest/coverage',
15+
collectCoverageFrom: [
16+
'<rootDir>/src/**/*.vue',
17+
'<rootDir>/src/**/*.js',
18+
'<rootDir>/src/**/*.ts',
19+
'<rootDir>/src/**/*.jsx'
20+
],
21+
coverageThreshold: {
22+
global: {
23+
// branches: 50,
24+
// functions: 50,
25+
// lines: 50,
26+
// statements: 50
27+
}
28+
},
29+
testMatch: [
30+
'<rootDir>/test/jest/__tests__/**/*.spec.js',
31+
'<rootDir>/test/jest/__tests__/**/*.test.js',
32+
'<rootDir>/src/**/__tests__/*_jest.spec.js'
33+
],
34+
moduleFileExtensions: [
35+
'vue',
36+
'js',
37+
'jsx',
38+
'json',
39+
'ts',
40+
'tsx'
41+
],
42+
moduleNameMapper: {
43+
'^vue$': '<rootDir>/node_modules/vue/dist/vue.common.js',
44+
'^test-utils$': '<rootDir>/node_modules/@vue/test-utils/dist/vue-test-utils.js',
45+
'^quasar$': '<rootDir>/node_modules/quasar/dist/quasar.common.js',
46+
'^~/(.*)$': '<rootDir>/$1',
47+
'^src/(.*)$': '<rootDir>/src/$1',
48+
'.*css$': '<rootDir>/test/jest/utils/stub.css'
49+
},
50+
transform: {
51+
'.*\\.vue$': 'vue-jest',
52+
'.*\\.js$': 'babel-jest',
53+
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
54+
// use these if NPM is being flaky
55+
// '.*\\.vue$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/vue-jest',
56+
// '.*\\.js$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/babel-jest'
57+
},
58+
transformIgnorePatterns: [
59+
'<rootDir>/node_modules/(?!quasar/lang)'
60+
],
61+
snapshotSerializers: [
62+
'<rootDir>/node_modules/jest-serializer-vue'
63+
]
64+
}

0 commit comments

Comments
 (0)