使用 --detectOpenHandles --forceExit 开玩笑 运行 有副作用吗?
are there side effects of running jest with --detectOpenHandles --forceExit?
我正在使用 jest
进行测试,在一些测试场景中我收到 jest
消息:
Jest did not exit one second after the test run has completed.
在将 Jest 的建议带到 运行 和 --detectOpenHandles
并以永无止境的挂起测试过程结束时,我看到其他在线建议也添加了 --forceExit
选项。现在测试结束,一切正常
值得一提的是,无论有无 --detectOpenHandles --forceExit
选项,所有测试都 运行 正常并通过。
我想知道在这种情况下这是否被视为最佳做法?或者它只是为我服务 "first aid"?
这样做有什么副作用?
干杯,
根据文档,detectOpenHandles
选项适用于:
Attempt to collect and print open handles preventing Jest from exiting cleanly. Use this in cases where you need to use --forceExit in order for Jest to exit to potentially track down the reason. This implies --runInBand, making tests run serially. Implemented using async_hooks, so it only works in Node 8 and newer. This option has a significant performance penalty and should only be used for debugging.
永远不要将 forceExit
选项用作最佳实践,唯一需要使用的情况是因为:
- 一个异步函数没有完成
- promise 函数未完成
- Websocket 连接仍然打开
- 数据库连接仍然打开
- 所有具有 connect/disconnect 方法的东西在测试结束前都没有断开连接
我正在使用 jest
进行测试,在一些测试场景中我收到 jest
消息:
Jest did not exit one second after the test run has completed.
在将 Jest 的建议带到 运行 和 --detectOpenHandles
并以永无止境的挂起测试过程结束时,我看到其他在线建议也添加了 --forceExit
选项。现在测试结束,一切正常
值得一提的是,无论有无 --detectOpenHandles --forceExit
选项,所有测试都 运行 正常并通过。
我想知道在这种情况下这是否被视为最佳做法?或者它只是为我服务 "first aid"? 这样做有什么副作用?
干杯,
根据文档,detectOpenHandles
选项适用于:
Attempt to collect and print open handles preventing Jest from exiting cleanly. Use this in cases where you need to use --forceExit in order for Jest to exit to potentially track down the reason. This implies --runInBand, making tests run serially. Implemented using async_hooks, so it only works in Node 8 and newer. This option has a significant performance penalty and should only be used for debugging.
永远不要将 forceExit
选项用作最佳实践,唯一需要使用的情况是因为:
- 一个异步函数没有完成
- promise 函数未完成
- Websocket 连接仍然打开
- 数据库连接仍然打开
- 所有具有 connect/disconnect 方法的东西在测试结束前都没有断开连接