Closed dum3ng closed 4 years ago
yarn add ts-jest
module.exports = { moduleNameMapper: { '^@/(.*)$': '<rootDir>/$1', '^~/(.*)$': '<rootDir>/$1', '^vue$': 'vue/dist/vue.common.js', }, moduleFileExtensions: ['js', 'vue', 'json', 'ts'], transform: { '^.+\\.(js|ts)$': '<rootDir>/node_modules/ts-jest/preprocessor.js', '.*\\.(vue)$': 'vue-jest', }, }
Worth to notice is that moduleFileExtensions and transform:
moduleFileExtensions
transform
ts
yarn add -D @types/jest
then add the type definition in tsconfig.json:
tsconfig.json
{ "types": ["jest"] }
install ts-jest
configure jest config
Worth to notice is that
moduleFileExtensions
andtransform
:ts
to make the transformer take the files as moduleadd typescript support
then add the type definition in
tsconfig.json
:references