【发布时间】:2020-06-14 22:03:15
【问题描述】:
尝试使用 Jest 测试 Angular 9 库,我已经在本地库 package.json 中安装了 Jest 和 Typescript 的依赖项,如下所示:
"devDependencies": {
"@types/jest": "^25.1.3",
"jest": "^25.1.0",
"ts-jest": "^25.2.1"
},
并且还像这样设置jest.config.js:
module.exports = {
"roots": [
"<rootDir>/src/"
],
testMatch: [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
}
}
但是看起来 jest 没有通过 ts-jest 转换,因为我遇到了这样的错误:
SyntaxError: Unexpected token export
> 1 | import assertString from './util/assertString';
| ^
2 | import toString from './util/toString';```
【问题讨论】:
标签: javascript angular typescript jestjs angular-library