升级到 Angular 版本 11 后,单元测试现在在 Travis CI 上失败。在本地,它们确实成功了(即使在使用相同的节点、nvm 和 npm 版本进行全新安装之后)。
所有单元测试的错误都是一样的 -
Failed: fn.bind is not a function
TypeError: fn.bind is not a function
at newTrustedFunctionForJIT (node_modules/@angular/compiler/fesm2015/compiler.js:6845:1)
at JitEvaluator.evaluateCode (node_modules/@angular/compiler/fesm2015/compiler.js:6909:1)
at JitEvaluator.evaluateStatements (node_modules/@angular/compiler/fesm2015/compiler.js:6883:1)
根据错误消息,我认为该问题可能与 ngcc?有人有类似的问题吗?
最佳答案
今天我遇到了同样的问题。它涉及使用 ChromeHeadless 进行测试。
我在 docker 镜像中安装了旧版本的 Chrome Headless 83.0.4103.97。将其更新到最新版本 88.0.4324.96 后,它开始工作。
关于Angular 单元测试失败,但不在本地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65826615/