Skip to content

Commit

Permalink
test: test jest plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 15, 2018
1 parent ea2648e commit 27ba51f
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
},
"devDependencies": {
"axios": "^0.17.1",
"babel-core": "^7.0.0-0",
"debug": "^3.1.0",
"eslint": "^4.14.0",
"eslint-plugin-vue-libs": "^2.1.0",
Expand All @@ -51,7 +52,6 @@
"lint-staged": "^6.0.0",
"memfs": "^2.6.0",
"puppeteer": "^0.13.0",
"yorkie": "^1.0.2",
"babel-core": "^7.0.0-0"
"yorkie": "^1.0.2"
}
}
12 changes: 10 additions & 2 deletions packages/@vue/cli-plugin-typescript/__tests__/tsPluginTest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jest.setTimeout(20000)

const create = require('@vue/cli-test-utils/createTestProject')

test('should work', async () => {
test('mocha', async () => {
const project = await create('ts-unit-mocha', {
plugins: {
'@vue/cli-plugin-typescript': {},
Expand All @@ -12,4 +12,12 @@ test('should work', async () => {
await project.run(`vue-cli-service test`)
})

// TODO jest
test('jest', async () => {
const project = await create('ts-unit-jest', {
plugins: {
'@vue/cli-plugin-typescript': {},
'@vue/cli-plugin-unit-jest': {}
}
})
await project.run(`vue-cli-service test`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
<%_ } _%>
<%_ if (hasJest) { _%>
"allowSyntheticDefaultImports": true,
<%_ } _%>
"sourceMap": true,
"baseUrl": ".",
"paths": {
Expand Down
5 changes: 5 additions & 0 deletions packages/@vue/cli-plugin-unit-jest/__tests__/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"vue-libs/no-async-functions": 0
}
}
25 changes: 25 additions & 0 deletions packages/@vue/cli-plugin-unit-jest/__tests__/jestGenerator.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const generateWithPlugin = require('@vue/cli-test-utils/generateWithPlugin')

test('base', async () => {
const { pkg, files } = await generateWithPlugin([
{
id: 'unit-jest',
apply: require('../generator'),
options: {}
},
// mock presence of the eslint plugin
{
id: 'eslint',
apply: () => {},
options: {}
}
])

expect(pkg.scripts.test).toBeTruthy()
expect(pkg.devDependencies).toHaveProperty('@vue/test-utils')
expect(pkg.devDependencies).toHaveProperty('babel-jest')
expect(files['test/unit/.eslintrc']).toMatch('"jest": true')

const spec = files['test/unit/HelloWorld.spec.js']
expect(spec).toMatch(`expect(wrapper.text()).toMatch(msg)`)
})
13 changes: 13 additions & 0 deletions packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
jest.setTimeout(20000)

const create = require('@vue/cli-test-utils/createTestProject')

test('should work', async () => {
const project = await create('unit-jest', {
plugins: {
'@vue/cli-plugin-babel': {},
'@vue/cli-plugin-unit-jest': {}
}
})
await project.run(`vue-cli-service test`)
})
2 changes: 1 addition & 1 deletion scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ if (!regex && packages.length) {
stdio: 'inherit'
})
})().catch(err => {
console.error(err)
err
process.exit(1)
})
5 changes: 3 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ babel-plugin-syntax-object-rest-spread@^6.13.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"

babel-plugin-transform-es2015-modules-commonjs@^6.24.1:
babel-plugin-transform-es2015-modules-commonjs@^6.24.1, babel-plugin-transform-es2015-modules-commonjs@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a"
dependencies:
Expand Down Expand Up @@ -9221,8 +9221,9 @@ vue-hot-reload-api@^2.2.0:

vue-jest@yyx990803/vue-jest:
version "1.4.0"
resolved "https://codeload.github.com/yyx990803/vue-jest/tar.gz/73e97676882fb133aedadce66a7d811154c412bf"
resolved "https://codeload.github.com/yyx990803/vue-jest/tar.gz/2ce12141b70161893982325ea72f1f2dcfdc6f04"
dependencies:
babel-plugin-transform-es2015-modules-commonjs "^6.26.0"
chalk "^2.1.0"
find-babel-config "^1.1.0"
js-beautify "^1.6.14"
Expand Down

0 comments on commit 27ba51f

Please sign in to comment.