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 = {
root: true,
env: {
node: true,
},
extends: [
// vue/recommended includes all higher levels (vue/strongly-recommended, vue/essential)
'plugin:vue/recommended',
@ -11,12 +13,15 @@ module.exports = {
'@vue/prettier',
'@vue/prettier/@typescript-eslint',
],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaVersion: 2020,
},
rules: {
'no-console': 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
'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
run: |
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": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint",
"lint-ci": "vue-cli-service lint --no-fix"
},
@ -27,17 +28,20 @@
},
"devDependencies": {
"@types/echarts": "^4.9.0",
"@types/jest": "^24.0.19",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^4.6.1",
"@vue/cli-plugin-babel": "~4.5.8",
"@vue/cli-plugin-eslint": "~4.5.8",
"@vue/cli-plugin-router": "^4.5.7",
"@vue/cli-plugin-typescript": "~4.5.8",
"@vue/cli-plugin-unit-jest": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.8",
"@vue/cli-service": "~4.5.8",
"@vue/eslint-config-airbnb": "^5.1.0",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^5.1.0",
"@vue/test-utils": "^1.0.3",
"eslint": "^6.7.2",
"eslint-config-airbnb": "^18.2.1",
"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

@ -1,30 +1,29 @@
{
"compilerOptions": {
"target": "es2020",
"module": "es2020",
// this enables stricter inference for data properties on `this`
"strict": true,
// if using webpack 2+ or rollup, to leverage tree shaking:
"moduleResolution": "node",
"experimentalDecorators": true,
"noImplicitAny": false,
"allowJs": true,
"sourceMap": true,
"baseUrl": "src",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"./*"
]
}
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
]
"compilerOptions": {
"target": "es2020",
"module": "es2020",
"strict": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"noImplicitAny": false,
"allowJs": true,
"sourceMap": true,
"baseUrl": "src",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"./*"
]
}
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
]
}

1888
yarn.lock

File diff suppressed because it is too large Load Diff