Add testing

This commit is contained in:
Matthias 2020-11-10 20:52:39 +01:00
parent 9265a6de53
commit d07de9d163
7 changed files with 1915 additions and 65 deletions

View File

@ -1,8 +1,10 @@
module.exports = { module.exports = {
root: true, root: true,
env: { env: {
node: true, node: true,
}, },
extends: [ extends: [
// vue/recommended includes all higher levels (vue/strongly-recommended, vue/essential) // vue/recommended includes all higher levels (vue/strongly-recommended, vue/essential)
'plugin:vue/recommended', 'plugin:vue/recommended',
@ -11,12 +13,15 @@ module.exports = {
'@vue/prettier', '@vue/prettier',
'@vue/prettier/@typescript-eslint', '@vue/prettier/@typescript-eslint',
], ],
parser: 'vue-eslint-parser', parser: 'vue-eslint-parser',
parserOptions: { parserOptions: {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
sourceType: 'module', sourceType: 'module',
ecmaVersion: 2020, ecmaVersion: 2020,
}, },
rules: { rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
@ -24,4 +29,13 @@ module.exports = {
// disable eslint no-shadow as it's causing false positives on typescript enums // disable eslint no-shadow as it's causing false positives on typescript enums
'no-shadow': 'off', 'no-shadow': 'off',
}, },
overrides: [
{
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
env: {
jest: true,
},
},
],
}; };

View File

@ -25,3 +25,7 @@ jobs:
- name: Run Lint - name: Run Lint
run: | run: |
yarn lint-ci yarn lint-ci
- name: Run Tests
run: |
yarn test:unit

3
jest.config.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
};

View File

@ -5,6 +5,7 @@
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint", "lint": "vue-cli-service lint",
"lint-ci": "vue-cli-service lint --no-fix" "lint-ci": "vue-cli-service lint --no-fix"
}, },
@ -27,17 +28,20 @@
}, },
"devDependencies": { "devDependencies": {
"@types/echarts": "^4.9.0", "@types/echarts": "^4.9.0",
"@types/jest": "^24.0.19",
"@typescript-eslint/eslint-plugin": "^2.33.0", "@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^4.6.1", "@typescript-eslint/parser": "^4.6.1",
"@vue/cli-plugin-babel": "~4.5.8", "@vue/cli-plugin-babel": "~4.5.8",
"@vue/cli-plugin-eslint": "~4.5.8", "@vue/cli-plugin-eslint": "~4.5.8",
"@vue/cli-plugin-router": "^4.5.7", "@vue/cli-plugin-router": "^4.5.7",
"@vue/cli-plugin-typescript": "~4.5.8", "@vue/cli-plugin-typescript": "~4.5.8",
"@vue/cli-plugin-unit-jest": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.8", "@vue/cli-plugin-vuex": "~4.5.8",
"@vue/cli-service": "~4.5.8", "@vue/cli-service": "~4.5.8",
"@vue/eslint-config-airbnb": "^5.1.0", "@vue/eslint-config-airbnb": "^5.1.0",
"@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^5.1.0", "@vue/eslint-config-typescript": "^5.1.0",
"@vue/test-utils": "^1.0.3",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-config-airbnb": "^18.2.1", "eslint-config-airbnb": "^18.2.1",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",

View File

@ -0,0 +1,12 @@
import { mount } from '@vue/test-utils';
import ValuePair from '@/components/ftbot/ValuePair.vue';
describe('ValuePair.vue', () => {
it('renders description when passed', () => {
const msg = 'Test description';
const wrapper = mount(ValuePair, {
propsData: { description: msg },
});
expect(wrapper.text()).toMatch(msg);
});
});

View File

@ -2,9 +2,7 @@
"compilerOptions": { "compilerOptions": {
"target": "es2020", "target": "es2020",
"module": "es2020", "module": "es2020",
// this enables stricter inference for data properties on `this`
"strict": true, "strict": true,
// if using webpack 2+ or rollup, to leverage tree shaking:
"moduleResolution": "node", "moduleResolution": "node",
"experimentalDecorators": true, "experimentalDecorators": true,
"noImplicitAny": false, "noImplicitAny": false,
@ -12,7 +10,8 @@
"sourceMap": true, "sourceMap": true,
"baseUrl": "src", "baseUrl": "src",
"types": [ "types": [
"webpack-env" "webpack-env",
"jest"
], ],
"paths": { "paths": {
"@/*": [ "@/*": [

1888
yarn.lock

File diff suppressed because it is too large Load Diff