first app draft
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
rootDir: path.resolve(__dirname, '..'),
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{js,vue}'
|
||||
],
|
||||
coverageDirectory: '<rootDir>/test/coverage',
|
||||
moduleFileExtensions: [
|
||||
'js',
|
||||
'vue'
|
||||
],
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1'
|
||||
},
|
||||
transform: {
|
||||
'^.+\\.js$': 'babel-jest',
|
||||
'^.+\\.vue$': 'vue-jest'
|
||||
},
|
||||
snapshotSerializers: [
|
||||
'<rootDir>/node_modules/jest-serializer-vue'
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import Posts from '@/components/Home/Posts'
|
||||
|
||||
// https://alligator.io/vuejs/testing-vue-with-jest/
|
||||
// https://www.synbioz.com/blog/testez_unitairement_application_vuejs_jest
|
||||
|
||||
function mountComponentWithProps (Component, propsData) {
|
||||
const Constructor = Vue.extend(Component);
|
||||
const vm = new Constructor({
|
||||
propsData
|
||||
}).$mount();
|
||||
|
||||
return vm.$el;
|
||||
}
|
||||
|
||||
describe('Posts.vue', () => {
|
||||
it('posts should not be empty', () => {
|
||||
const PostsData = mountComponentWithProps(Posts, { all: [] });
|
||||
const allData = PostData.all;
|
||||
|
||||
console.log(allData)
|
||||
|
||||
expect(allData).toBe([])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user