[Support] 新建的midwayjs项目为什么使用jest会报错? #3687
Replies: 1 comment
-
这是 egg 的报错,你必须使用 ts-node 来执行。
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the problem(描述问题)
操作步骤
npm init midway@latest -y
cd midway-project cnpm install
"nodetest": "jest",
npm run nodetest
src>config>plugin.ts
8.再次执行单测
9.运行正常
` PASS test/controller/api.test.ts
PASS test/controller/home.test.ts
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
Test Suites: 2 passed, 2 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 5.208 s`
Midway Versions(Midway 版本)
{
"name": "my-midway-project",
"version": "1.0.0",
"description": "",
"private": true,
"dependencies": {
"@midwayjs/bootstrap": "^3.12.0",
"@midwayjs/core": "^3.12.0",
"@midwayjs/web": "^3.12.0",
"@midwayjs/decorator": "^3.12.0",
"@midwayjs/logger": "^3.1.0",
"egg": "^2.0.0"
},
"devDependencies": {
"@midwayjs/egg-ts-helper": "^1.0.1",
"@midwayjs/mock": "^3.12.0",
"@types/jest": "^29.2.0",
"@types/node": "14",
"cross-env": "^6.0.0",
"egg-mock": "^3.26.0",
"mwts": "^1.3.0",
"mwtsc": "^1.4.0",
"jest": "^29.2.2",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.2",
"typescript": "~4.8.0"
},
"engines": {
"node": ">=12.0.0"
},
"scripts": {
"nodetest": "jest"
}
}
Beta Was this translation helpful? Give feedback.
All reactions