我已经用Angular CLI设置了我的项目。我也通过"ng g component NAME“创建了我的组件。这也自动添加了一个test-class来创建我的单元测试(这当然非常整洁)。
问题是,我的测试很难失败,即使我把它们留在初始状态。我想在真正写任何测试之前测试一下。然而,测试失败得很可怕。没有一行代码执行得很好。
> ng test
'app-some-selector' is not a known element:
1. If 'app-some-selector' is an Angular component, then ver
在使用angular-cli创建新组件时,预期的行为是使用描述新创建的组件的条目更新angular.json.projects。观察到的行为是angular-cli没有这样做。
在运行ng test newComponent并接收到消息Project 'inline' does not support the 'test' target.之后,我发现了这一点。
在我更新ng test newComponent来描述新创建的组件之后,angular.json.projects就开始工作了。
我正在将一个角2组件库迁移到新的角7工作区模型。我正在使用Todd的配方从
我的任务是为我们团队正在开发的应用程序的组件编写Karma/Jasmine测试。我不是写实际组件的人,我遇到了一个错误,到目前为止我还没有找到答案。
这是deleteuser.component.ts代码:
import {MatTableDataSource} from '@angular/material/table';
import {MatSort} from '@angular/material/sort';
import {MatPaginator} from '@angular/material/paginator';
import
当我在安圭拉8的角度材料组件项目中运行ng test时,我遇到了多个失败。我还没有为这些场景编写任何特定的测试用例。
DeleteBotModalComponent > should create
Failed: Template parse errors:
'mat-label' is not a known element:
1. If 'mat-label' is an Angular component, then verify that it is part of this module.
2. If 'mat-label' is
关于覆盖Angular单元测试中的模板,我有一个假设的问题(如果这不是一个合适的问题,请建议关闭它,而不是标记它,我将删除/关闭该问题)。我的团队成员更喜欢在Angular中进行单元测试时覆盖HTML模板,所以如果我有一个测试,它将如下所示:
describe('MyWhateverComponent', () => {
let component: MyWhateverComponent;
let fixture: ComponentFixture<MyWhateverComponent>;
// lots more things here re
我们有一个Angular 10应用程序,使用无头Chrome在Karma中运行了大约600个Jasmine测试。 最近,其中一个测试开始失败,并出现"An error in in beforeEach“错误。找出哪个测试失败的最佳方法是什么? 我尝试在Karma配置中添加一些记者,这样我就可以看到正在执行哪些测试。我尝试过的记者在测试执行后打印出了每个测试的名称,但是由于测试在beforeEach方法中失败了,所以这个名称从未打印出来。我试着寻找在测试执行之前打印测试名称的记者,但我找不到一个。最后,我做了一个二进制搜索,删除了一半的测试套件,直到我发现哪个测试失败了,但我相信肯定有
我添加了从检索的示例(这个示例可以看到)文档,但是它会抛出这个错误:
Can't bind to 'dataSource' since it isn't a known property of 'mat-tree'.
1. If 'mat-tree' is an Angular component and it has 'dataSource' input, then verify that it is part of this module.
2. If 'mat-tree' is a Web C
在阅读了这个之后,我决定测试我的简单登录页面,它只包含两个输入框和一个提交按钮。然后,组件使用LoginService将这些数据传递给后端。
(还请注意,我对这种单元测试还是新手,所以我不确定这是否是一个很好的方法来测试这样的组件。)
首先,我只想检查#username输入元素的初始值是否为空。但由于以下报告的问题,我甚至无法使规范工作:
Chrome 55.0.2883 (Windows 7 0.0.0) LoginComponent Username field should be empty FAILED
Failed: Unexpected value 'Htt
在创建了一个新组件之后,我在几乎所有的测试中都收到了这个错误: SampleComponent > should create
Failed: Component TuzGraphComponent is not part of any NgModule or the module has not been imported into your module.
Error: Component TuzGraphComponent is not part of any NgModule or the module has not been imported into your modul
我有一个角组件,作为其他组件的正面。这是使用ComponentFactoryResolver实现的。当我将管道引入其中一个生成的组件时,我的单元测试开始以一种奇怪的方式失败。
,我希望有人能解释为什么会这样失败?
Failed: NG0302: The pipe 'displayValue' could not be found!. Find more at https://angular.io/errors/NG0302
error properties: Object({ code: '302' })
Erro
我使用角-cli与angular2 v4.0与角材料.
所有错误都是Dudes..what吗?我正在努力学习因果报应,如果我进行npm测试,我会得到34次与材料有关的失败。例如:
Can't bind to 'routerLinkActive' since it isn't a known property of 'a'
Can't bind to 'md-menu-trigger-for' since it isn't a known property of 'button'
Can't
我正在使用一个从Angular 8到10的应用程序,看起来好像我搞砸了什么。我有一些解析器,其中一个给我一个错误。我不知道导致问题的实体或数据服务有什么不同。我也不确定这个错误消息声称丢失了什么,以及它应该在哪里。 Uncaught (in promise): Error: No EntityDefinition for entity type "makVersion". 这是令人不快的特性模块。 // Standard Angular Items
import { NgModule } from '@angular/core';
import { Route
我正在使用Angular2.0.1,并试图围绕带有一些异步任务的角组件编写单元测试。我想说,这是一件相当平常的事。即使是他们的最新测试示例也包括此类异步测试(请参阅)。
但是,我自己的测试永远不会成功,总是在信息方面失败。
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
长话短说,我花了几个小时找出问题的真正根源。我正在使用库angular2,在那里,我使用了一个叫做amTimeAgo的管道。此管道包含一个window.se