小编Sha*_*ker的帖子

我应该在端到端测试中模拟 API 吗?

当您对应用程序进行端到端测试时,您希望测试整个应用程序,而不是测试其中的某些部分,例如单元测试或集成测试。

但在某些情况下,人们会模拟 API。
例如,当你有一个庞大的微服务作为后端时,这使得你的 e2e 测试非常慢,或者除了你自己的 API 之外,你还依赖其他第三方 API,这使得你的 e2e 测试偶尔会失败。
所以你只想确保你的前端应用程序运行良好,你应该做什么?

在我的公司,我们有一个庞大的系统和一个非常重的数据库,这使得 e2e 测试非常低效。在这种情况下模拟 API 是否正确?

testing automated-tests end-to-end

13
推荐指数
1
解决办法
7660
查看次数

NG3003:库中的 Angular 12 循环依赖项 - Ivy 部分编译模式

我在这里提出一个问题。
\n我有一个ParentComponent它有一个 child ChildComponent,\nchildParentComponent里面有它,所以这里有一个循环。
\n这是我面临的错误:

\n
\xe2\x9c\x96 Compiling with Angular sources in Ivy partial compilation mode.\nERROR: projects/api/src/lib/api.component.ts:3:1\nerror NG3003: One or more import cycles would need to be created to \ncompile this component, which is not supported by the current compiler\nconfiguration.\n\nThe component \'ParentComponent\' is used in the template but importing\nit would create a cycle:\n /lib/child/child.component.ts -> /lib/parent/parent.component.ts -> /lib/child/child.component.ts\n
Run Code Online (Sandbox Code Playgroud)\n

此错误仅发生在 Angular 库中。正如您所看到的, stackblitz示例中没有问题,它只是一个演示。

\n

"compilationMode": "full"这个错误会随着库文件中的设置而消失tsconfig.lib.prod.json,但在这种情况下,我们会失去向后兼容性!\n

\n

官方文档说:

\n …

circular-dependency angular angular-library angular-ivy angular12

5
推荐指数
1
解决办法
3020
查看次数

Angular Material:创建自定义表单字段控件时,mat-form-field 必须包含 MatFormFieldControl

我想按照本指南实现 Angular Material 自定义表单字段: https: //material.angular.io/guide/creating-a-custom-form-field-control

但我一直遇到此错误:错误错误:mat-form-field 必须包含 MatFormFieldControl。

根据文档

当您尚未将表单字段控件添加到表单字段时,会出现此错误。如果您的表单字段包含本机或元素,请确保已向其中添加 matInput 指令并导入 MatInputModule。其他可以充当表单字段控件的组件包括 、 和您创建的任何自定义表单字段控件。

但是向标签添加 matInput 指令不会改变任何内容。就像它是盲目的,因为标签嵌入在这个新组件中<example-tel-input>

垫子形式字段:

<mat-form-field>
  <example-tel-input placeholder="Phone number" required></example-tel-input>
  <mat-icon matSuffix>phone</mat-icon>
  <mat-hint>Include area code</mat-hint>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)

具有输入的组件:

<div [formGroup]="parts" class="example-tel-input-container">
  <input class="example-tel-input-element" formControlName="area" size="3" aria-label="Area code" (input)="_handleInput()">
  <span class="example-tel-input-spacer">&ndash;</span>
  <input class="example-tel-input-element" formControlName="exchange" size="3" aria-label="Exchange code" (input)="_handleInput()">
  <span class="example-tel-input-spacer">&ndash;</span>
  <input class="example-tel-input-element" formControlName="subscriber" size="4" aria-label="Subscriber number" (input)="_handleInput()">
</div>
Run Code Online (Sandbox Code Playgroud)

Stackblitz: https: //stackblitz.com/edit/angular-9fyeha

我缺少什么?

angular-material angular

4
推荐指数
1
解决办法
2万
查看次数