Skip to content

Commit 0e1ff81

Browse files
authored
Merge pull request #29 from citation-file-format/test-config
Test config
2 parents e573548 + bbcd29e commit 0e1ff81

32 files changed

Lines changed: 25656 additions & 12981 deletions

.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+
}

README.dev.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,18 @@ To run linting on commit, you can install a git commit hook with
5757
```shell
5858
npx husky install
5959
```
60+
61+
## Tests
62+
63+
We use Jest for unit tests. To run unit tests (`src/**/*.jest.spec.ts`)
64+
65+
You can run the test with
66+
67+
```shell
68+
npm run test:unit:ci
69+
```
70+
71+
You can also use the Majestic web interface to run the unit tests in your browser.
72+
73+
```shell
74+
npm run test:unit:ui

babel.config.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/* eslint-env node */
2+
// eslint-disable-next-line @typescript-eslint/no-var-requires
3+
const fs = require('fs-extra');
4+
let extend = undefined;
25

3-
module.exports = api => {
4-
return {
5-
presets: [
6-
[
7-
'@quasar/babel-preset-app',
8-
api.caller(caller => caller && caller.target === 'node')
9-
? { targets: { node: 'current' } }
10-
: {}
11-
]
12-
]
13-
}
6+
/**
7+
* The .babelrc file has been created to assist Jest for transpiling.
8+
* You should keep your application's babel rules in this file.
9+
*/
10+
11+
if (fs.existsSync('./.babelrc')) {
12+
extend = './.babelrc';
1413
}
1514

15+
module.exports = {
16+
presets: ['@quasar/babel-preset-app'],
17+
extends: extend,
18+
};

jest.config.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const esModules = ['quasar/lang', 'lodash-es'].join('|')
2+
3+
/* eslint-env node */
4+
module.exports = {
5+
globals: {
6+
__DEV__: true,
7+
// TODO: Remove if resolved natively
8+
// See https://github.com/vuejs/vue-jest/issues/175
9+
'vue-jest': {
10+
pug: { doctype: 'html' }
11+
}
12+
},
13+
// noStackTrace: true,
14+
// bail: true,
15+
// cache: false,
16+
// verbose: true,
17+
// watch: true,
18+
collectCoverage: false,
19+
coverageDirectory: '<rootDir>/test/jest/coverage',
20+
collectCoverageFrom: [
21+
'<rootDir>/src/**/*.vue',
22+
'<rootDir>/src/**/*.js',
23+
'<rootDir>/src/**/*.ts',
24+
'<rootDir>/src/**/*.jsx',
25+
'<rootDir>/src/**/*.tsx'
26+
],
27+
coveragePathIgnorePatterns: ['/node_modules/', '.d.ts$'],
28+
coverageThreshold: {
29+
global: {
30+
// branches: 50,
31+
// functions: 50,
32+
// lines: 50,
33+
// statements: 50
34+
}
35+
},
36+
testMatch: [
37+
// Matches tests in any subfolder of 'src' or into 'test/jest/__tests__'
38+
// Matches all files with extension 'js', 'jsx', 'ts' and 'tsx'
39+
'<rootDir>/test/jest/__tests__/**/*.(spec|test).+(ts|js)?(x)',
40+
'<rootDir>/src/**/*.jest.(spec|test).+(ts|js)?(x)'
41+
],
42+
// Extension-less imports of components are resolved to .ts files by TS,
43+
// grating correct type-checking in test files.
44+
// Being 'vue' the first moduleFileExtension option, the very same imports
45+
// will be resolved to .vue files by Jest, if both .vue and .ts files are
46+
// in the same folder.
47+
// This guarantee a great dev experience both for testing and type-checking.
48+
// See https://github.com/vuejs/vue-jest/issues/188#issuecomment-620750728
49+
moduleFileExtensions: ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'],
50+
moduleNameMapper: {
51+
'^~/(.*)$': '<rootDir>/$1',
52+
'^src/(.*)$': '<rootDir>/src/$1',
53+
'^app/(.*)$': '<rootDir>/$1',
54+
'^components/(.*)$': '<rootDir>/src/components/$1',
55+
'^layouts/(.*)$': '<rootDir>/src/layouts/$1',
56+
'^pages/(.*)$': '<rootDir>/src/pages/$1',
57+
'^assets/(.*)$': '<rootDir>/src/assets/$1',
58+
'^boot/(.*)$': '<rootDir>/src/boot/$1',
59+
'.*css$': '@quasar/quasar-app-extension-testing-unit-jest/stub.css'
60+
},
61+
transform: {
62+
// See https://jestjs.io/docs/en/configuration.html#transformignorepatterns-array-string
63+
[`^(${esModules}).+\\.js$`]: 'babel-jest',
64+
'^.+\\.(ts|js|html)$': 'ts-jest',
65+
// vue-jest uses find-babel-file, which searches by this order:
66+
// (async) .babelrc, .babelrc.js, package.json, babel.config.js
67+
// (sync) .babelrc, .babelrc.js, babel.config.js, package.json
68+
// https://github.com/tleunen/find-babel-config/issues/33
69+
'.*\\.vue$': 'vue-jest',
70+
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
71+
'jest-transform-stub'
72+
},
73+
transformIgnorePatterns: [`node_modules/(?!(${esModules}))`],
74+
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue']
75+
}

0 commit comments

Comments
 (0)