角度测试模式的NGXS测试在Angular 13中被损坏
我们正在研究一个Angular应用程序,该应用程序使用了NGXS(版本3.7.3)。目前,我们正在使用Angular 12.2,并希望升级到Angular 13。我们已成功地将应用程序升级到Angular 13,不幸的是,我们的大量单位测试失败了,所有这些单位测试都失败了,所有这些测试都与路由模块产生的异常相同。我们在堆栈痕迹中发现了NGXS-Router-Plugin,并试图找出发生了什么。 NGXS检查Angular是否在test模式中 - 函数iSangularInteStMode
在模块中/internals/src/angular.ts
- 并相应地配置自己。此支票打破了。
我们已经看到NGXS已解决了问题 - 可以在主分支上找到修复程序。下一个版本到期时我们不会。有人知道下一个NGXS发布的时间吗?是否有人遇到同样的问题,如果是这样,您是否有解决方法?
We are working on an Angular application that uses among other things Ngxs (version 3.7.3). Currently we are using Angular 12.2 and want to upgrade to Angular 13. We have successfully upgraded the application to Angular 13, unfortunately a significant number of our unit tests are failing, all with the same exception generated by the routing module. We found the ngxs-router-plugin in the stack traces and tries to find out what was going on. NGXS checks if Angular is in test-mode - the function isAngularInTestMode
in module /internals/src/angular.ts
- and configures itself accordingly. This check is broken.
We have seen that ngxs has fixed the problem - the fix can be found on the master branch. We don't when the next release is due. Does anybody know when the next ngxs release is due? Is anybody else experiencing the same problem, and if so do you have a workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

在遇到完全相同的问题并进一步检查 NGXS 文档后,我发现开发版本可以从
master
分支获得 - 最初让我失望的是它们被标记为相同的版本前缀作为最后一个稳定
(标记最新
)版本。简而言之:解决方法是使用
dev
标签,或有效解决问题的开发版本 - 在本例中是3.7.3-dev.master-33cace6
After having the exact same issue and further checking the NGXS docs, I found that dev-builds are available from the
master
branch - the thing that initially threw me off was that they are labeled with the same version prefix as the laststable
(taglatest
) build.So in short: the workaround is to use the
dev
tag, or the dev-version that effectively fixed the issue - in this case3.7.3-dev.master-33cace6