add jest unit testing

This commit is contained in:
Eugene Serb 2022-12-18 12:10:37 +03:00
parent 368d94e4c0
commit 5d1f99ff23
7 changed files with 5032 additions and 9038 deletions

View File

@ -2,4 +2,3 @@
last 2 versions
not dead
not ie 11

View File

@ -15,4 +15,15 @@ module.exports = {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)',
],
env: {
jest: true,
},
},
],
};

3
jest.config.js Normal file
View File

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

14025
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,11 @@
"keywords": [
"wavelovers",
"gamepad-vibrator",
"gamepad-test-tool",
"gamepad-vibration-test-tool"
"gamepad-vibration-test-tool",
"gamepad-tester",
"gamepad-test-tool"
],
"version": "1.3.0",
"version": "1.3.1",
"license": "GNU GPL v3",
"homepage": "https://wavelovers.ru/",
"author": {
@ -26,6 +27,7 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
@ -37,19 +39,26 @@
"vuex": "^4.0.0"
},
"devDependencies": {
"@types/jest": "^27.0.1",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-typescript": "~5.0.0",
"@vue/cli-plugin-unit-jest": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@vue/eslint-config-typescript": "^9.1.0",
"@vue/test-utils": "^2.0.0-0",
"@vue/vue3-jest": "^27.0.0-alpha.1",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"jest": "^27.0.5",
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"ts-jest": "^27.0.4",
"typescript": "~4.5.5"
}
}

View File

@ -0,0 +1,12 @@
import { shallowMount } from '@vue/test-utils';
import MessageItem from '@/components/MessageItem.vue';
describe('MessageItem.vue', () => {
it('renders slots when passed', () => {
const msg = 'new message';
const wrapper = shallowMount(MessageItem, {
slots: { default: msg }
});
expect(wrapper.html()).toContain(msg);
});
});

View File

@ -13,7 +13,8 @@
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
"webpack-env",
"jest"
],
"paths": {
"@/*": [