Skip to content

Commit

Permalink
fix: allow user to define testMatch in package.json (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensche committed Apr 3, 2018
1 parent e65110f commit bcd92b1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/@vue/cli-plugin-unit-jest/__tests__/jestPlugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,25 @@ test('should work', async () => {
})
await project.run(`vue-cli-service test`)
})

test('should respect jest testMatch config', async () => {
const project = await create('unit-jest', {
plugins: {
'@vue/cli-plugin-babel': {},
'@vue/cli-plugin-unit-jest': {}
}
})
const config = JSON.parse(await project.read('package.json'))
config.jest.testMatch = ['custom-test-directory/my.spec.js']

await project.write('package.json', JSON.stringify(config))

let result
try {
await project.run(`vue-cli-service test`)
} catch (e) {
result = e
}
console.log(result)
expect(result.stdout).toMatch('custom-test-directory/my.spec.js')
})
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-jest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = api => {
const jestBinPath = require.resolve('jest/bin/jest')

let testMatch = []
if (!args._.length) {
if (!args._.length && !api.service.pkg.jest.testMatch) {
testMatch = [`--testMatch`, `<rootDir>/(tests/unit/**/*.spec.(ts|tsx|js)|**/__tests__/*.(ts|tsx|js))`]
}

Expand Down

0 comments on commit bcd92b1

Please sign in to comment.