cost 182 ms
在 angular 15 项目的 src 文件夹外进行业力测试 - Having karma tests outside src folder in angular 15 project

我在项目根级别的测试文件夹中的 src 文件夹外有业力测试规范文件。 将 angular 从 14 更新到 15 后,karma 需要测试规范文件位于 sourceRoot 在 angular.json 文件中指定的任何文件夹中。 有没有办法告诉 karma 在不更改 angular.json 中的 ...

异步等待嵌套在 Jasmine 测试中 - Async await nested in Jasmine test

我是 Jasmine 的新手,我正在尝试对连接进行单元测试,原来的 function 在隐身模式下检查浏览器,测试必须参考它并进行相应的检查。 然后我留下组件的代码: 现在这是我尝试进行相应验证的方式: 给我的结果如下在此处输入图像描述在覆盖结果中,代码不会通过这些行 ...

ng test 生成“TypeError: The 'compilation' argument must be an instance of Compilation”错误,但 ng build 有效 - ng test generates "TypeError: The 'compilation' argument must be an instance of Compilation" error, but ng build works

当我尝试使用“ng test libraryprojectname”运行单元测试时,出现以下错误。 ng build 工作正常。 有问题的项目是一个带有 angular 库的工作区。 关于寻找什么的任何指示? ...

window.location.protocol mock 的问题(jasmine,karma) - problem with window.location.protocol mock (jasmine, karma)

在 js 代码中,在我正在测试的方法中,我使用window.location.protcol来指定其中一个值。 我无法在规范中设置它,因为我收到如下消息:无法重新定义属性:位置我试过这个和其他许多人: spyOn(window.location, 'protocol').and.returnVal ...

“架构验证失败,出现以下错误:数据路径“”在运行“ng 测试”时应该具有必需的属性“karmaConfig”错误 - angular - "Schema validation failed with the following errors: Data path "" should have required property 'karmaConfig' error on running "ng test" - angular

我已经用 angular 开发了一段时间,但我从来没有为我的任何 angular 应用程序编写过单元测试。 我是单元测试的新手,遇到这个问题时正想着手进行单元测试。 使用我的 angular 应用程序设置并根据我运行“ng 测试”的文档来探索测试的工作原理,但我遇到了以下错误:“ “因为这个,我 ...

无法从 IntelliJ Ultimate 中的“测试运行”选项卡导航到 Karma 测试文件 - Can't navigate to Karma test file from Tests Run tab in IntelliJ Ultimate

我有一个带有 Karma/Jasmine 测试文件的 Angular 项目。 我配置了我的 IntelliJ IDEA(2022.2.4(终极版))来运行 Karma 测试,大部分情况下工作正常。 一件不起作用的事情是打开“测试运行”选项卡并通过单击测试名称导航到测试源。 例如在下面的屏幕截图中,我 ...

无法读取 null 的属性(读取“nativeElement”)- 测试 Angular - Cannot read properties of null (reading 'nativeElement') - Test Angular

我是 Angular 的新手,我正在尝试执行测试...我想在 component.ts 中测试我的 function,它通过单击接收事件,并且此值传递给组件 dad 的 output。 测试代码看起来像这样...... 组件.ts 组件 HTML: 我在版本 15 中使用 Angular/Cli, ...

当不满足覆盖要求时,业力覆盖不会使构建失败 - Karma coverage does not fail the build when the coverage requirements are not met

我将NRWL 的 NX与我的Angular应用程序一起使用,并使用以下命令在我的 CI 中运行单元测试: 当不满足代码覆盖率要求时,构建仍然通过,尽管我可以在构建日志中清楚地看到覆盖率错误: 07 12 2022 16:06:14.750:ERROR [coverage]:Chrome Headl ...

Angular 测试:为什么在尝试注入 mockService 时会出现 ReferenceError? - Angular test: why do I get a ReferenceError while attempting to inject a mockService?

我正在使用 Angular 14.2.0 项目(使用 ng cli 创建,tsconfig 和 angular.json 都没有变化)。 我正在尝试在注入服务 UserService 的组件上编写一个简单的测试。 我使用jasmine.createSpyObj来模拟该服务,但只要我在 TestBe ...

NullInjectorError: StaticInjectorError(ExampleModule)[RouterLinkWithHref -> Router]: NullInjectorError: 没有路由器的提供者 - NullInjectorError: StaticInjectorError(ExampleModule)[RouterLinkWithHref -> Router]: NullInjectorError: No provider for Router

我正在为 AppComponent 准备一个单元测试用例,它有一个路由器作为注入的依赖项,并且在我的测试台中包含了 RouterTestingModule。 仍然出现错误。 请找到如下所示的错误日志: ...

ng 测试完成后,在 /_karma_webpack_/polyfills.js 获取 Uncaught [object Object] - After completion of ng test, getting Uncaught [object Object] at /_karma_webpack_/polyfills.js

测试用例运行成功,但最后会返回一个 Uncaught [object Object] 错误,如下所示:- 测试脚本: ng test --codeCoverage=true --no-watch --no-progress --browsers=ChromeHeadless Angular: ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM