Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
feat: Support @vue/vue2-jest (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSuisse authored Feb 8, 2022
1 parent 8de3aba commit 595df2b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion jest.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { transform } = require('./dist/index')

function requireVueJest() {
const names = ['@vue/vue2-jest', 'vue-jest']
for (const name of names) {
try {
return require(name)
}
catch (e) {
// Try next module
}
}
throw new Error(`Cannot find a Jest transformer for Vue SFC, you should install one of these packages: ${names.join(', ')}`)
}

module.exports = {
process(source, filename, ...args) {
const transformed = transform(source, filename)
const code = transformed ? transformed.code : source
return require('vue-jest').process.call(this, code, filename, ...args)
return requireVueJest().process.call(this, code, filename, ...args)
},
}

0 comments on commit 595df2b

Please sign in to comment.