Angular 单元测试失败,但不是在本地

Angular unit tests fail, but not locally

升级到 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 后,它开始工作了。

另外here是对应的angulargithub问题

使用 Chrome >= 87 应该 fix 问题。