mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #55 from gradido/frontend-tets
Setup unit tests for frontend
This commit is contained in:
commit
57b3b56744
61
.github/workflows/test.yml
vendored
61
.github/workflows/test.yml
vendored
@ -214,41 +214,34 @@ jobs:
|
||||
# run: docker-compose exec -T backend yarn test
|
||||
|
||||
##############################################################################
|
||||
# JOB: UNIT TEST WEBAPP ######################################################
|
||||
# JOB: UNIT TEST FRONTEND ###################################################
|
||||
##############################################################################
|
||||
#unit_test_webapp:
|
||||
# name: Unit tests - webapp
|
||||
# runs-on: ubuntu-latest
|
||||
# needs: [build_test_webapp]
|
||||
# steps:
|
||||
# ##########################################################################
|
||||
# # CHECKOUT CODE ##########################################################
|
||||
# ##########################################################################
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v2
|
||||
# ##########################################################################
|
||||
# # DOWNLOAD DOCKER IMAGES #################################################
|
||||
# ##########################################################################
|
||||
# - name: Download Docker Image (Webapp)
|
||||
# uses: actions/download-artifact@v2
|
||||
# with:
|
||||
# name: docker-webapp-test
|
||||
# path: /tmp
|
||||
# - name: Load Docker Image
|
||||
# run: docker load < /tmp/webapp.tar
|
||||
# ##########################################################################
|
||||
# # UNIT TESTS WEBAPP #####################################################
|
||||
# ##########################################################################
|
||||
# # TODO: Why do we need those .envs?
|
||||
# - name: backend | copy env files webapp
|
||||
# run: cp webapp/.env.template webapp/.env
|
||||
# - name: backend | copy env files backend
|
||||
# run: cp backend/.env.template backend/.env
|
||||
# - name: backend | docker-compose
|
||||
# run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp
|
||||
# - name: webapp | Unit tests
|
||||
# #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test
|
||||
# run: docker-compose exec -T webapp yarn test
|
||||
unit_test_frontend:
|
||||
name: Unit tests - Frontend
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build_test_frontend]
|
||||
steps:
|
||||
##########################################################################
|
||||
# CHECKOUT CODE ##########################################################
|
||||
##########################################################################
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
##########################################################################
|
||||
# DOWNLOAD DOCKER IMAGES #################################################
|
||||
##########################################################################
|
||||
- name: Download Docker Image (Webapp)
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: docker-frontend-test
|
||||
path: /tmp
|
||||
- name: Load Docker Image
|
||||
run: docker load < /tmp/frontend.tar
|
||||
##########################################################################
|
||||
# UNIT TESTS FRONTEND ####################################################
|
||||
##########################################################################
|
||||
- name: frontend | Unit tests
|
||||
run: docker run --rm gradido/frontend:test yarn run test
|
||||
|
||||
|
||||
#test:
|
||||
# runs-on: ubuntu-latest
|
||||
|
||||
22
frontend/.babelrc
Normal file
22
frontend/.babelrc
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env"
|
||||
]
|
||||
],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["require-context-hook"],
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "10"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
2
frontend/.gitignore
vendored
2
frontend/.gitignore
vendored
@ -18,3 +18,5 @@ package-lock.json
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
|
||||
*~
|
||||
34
frontend/jest.config.js
Normal file
34
frontend/jest.config.js
Normal file
@ -0,0 +1,34 @@
|
||||
module.exports = {
|
||||
verbose: true,
|
||||
collectCoverageFrom: [
|
||||
"**/*.{js,vue}",
|
||||
"!**/node_modules/**",
|
||||
"!**/?(*.)+(spec|test).js?(x)"
|
||||
],
|
||||
moduleFileExtensions: [
|
||||
'js',
|
||||
//'jsx',
|
||||
'json',
|
||||
'vue',
|
||||
],
|
||||
coverageReporters: [
|
||||
"lcov"
|
||||
],
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1'
|
||||
},
|
||||
transform: {
|
||||
'^.+\\.vue$': 'vue-jest',
|
||||
// '.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
|
||||
"^.+\\.(js|jsx)?$": "babel-jest"
|
||||
},
|
||||
//setupFiles: [
|
||||
// "<rootDir>/test/registerContext.js"
|
||||
//],
|
||||
testMatch: [
|
||||
"**/?(*.)+(spec|test).js?(x)"
|
||||
],
|
||||
// snapshotSerializers: ['jest-serializer-vue'],
|
||||
transformIgnorePatterns: ['<rootDir>/node_modules/']
|
||||
};
|
||||
|
||||
@ -8,10 +8,15 @@
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"dev": "yarn run serve",
|
||||
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'"
|
||||
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vue/test-utils": "^1.1.3",
|
||||
"axios": "^0.21.1",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-jest": "^26.6.3",
|
||||
"babel-plugin-require-context-hook": "^1.0.0",
|
||||
"bootstrap": "4.3.1",
|
||||
"bootstrap-vue": "^2.5.0",
|
||||
"chart.js": "^2.9.3",
|
||||
@ -27,6 +32,7 @@
|
||||
"flatpickr": "^4.5.7",
|
||||
"fuse.js": "^3.2.0",
|
||||
"google-maps": "^3.2.1",
|
||||
"jest": "^26.6.3",
|
||||
"nouislider": "^12.1.0",
|
||||
"particles-bg-vue": "1.2.3",
|
||||
"perfect-scrollbar": "^1.3.0",
|
||||
@ -45,6 +51,7 @@
|
||||
"vue-flatpickr-component": "^8.1.2",
|
||||
"vue-good-table": "^2.21.3",
|
||||
"vue-i18n": "^8.22.4",
|
||||
"vue-jest": "^3.0.7",
|
||||
"vue-moment": "^4.1.0",
|
||||
"vue-qrcode": "^0.3.5",
|
||||
"vue-qrcode-reader": "^2.3.16",
|
||||
|
||||
32
frontend/src/components/CloseButton.spec.js
Normal file
32
frontend/src/components/CloseButton.spec.js
Normal file
@ -0,0 +1,32 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
|
||||
import CloseButton from './CloseButton'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
describe('CloseButton', () => {
|
||||
|
||||
let wrapper
|
||||
let propsData = {
|
||||
target: "Target",
|
||||
expanded: false,
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
return mount(CloseButton, { localVue, propsData })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('emmits click event', () => {
|
||||
wrapper.find('.navbar-toggler').trigger('click')
|
||||
expect(wrapper.emitted('click')).toBeTruthy()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
1897
frontend/yarn.lock
1897
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user