小编Mah*_*esh的帖子

如何在反应测试库中获得代码覆盖率

我已经使用 react 测试库(@testing-library/react & @testing-library/dom)和 jest-dom(@testing-library/jest-dom)编写了单元测试。我能够成功运行我的测试。

我没有使用 jest/jest-cli complete pacakge。我正在使用反应测试库和那个 jest-dom(@testing-library/jest-dom) 它可能是一些子包或我不确定到底该叫它什么的东西。

如何使用反应测试库获得代码覆盖率?

在此处输入图片说明

reactjs react-testing-library

13
推荐指数
3
解决办法
9228
查看次数

如何在角度模板驱动的表单模型中使用fieldset表示数组?

我有一个具有嵌套对象数组的表单.为了表示多级表单视图模型,我们使用ngModelGroup来映射父子关系.有没有办法使用类似于ngModelGroup的指令来表示数组?

以下是模特,

export class SurveyViewModel {
Survey: Survey;
QuestionAnswerSets: QuestionAnswerSet[];
}

export class Survey {
Id: string;
Name: string;   
}


export class QuestionAnswerSet {
Question: Question;
Answers: Answer[];
}
Run Code Online (Sandbox Code Playgroud)

下面是视图,

  <form [formGroup]="surveyForm" (ngSubmit)="onFormSubmit(surveyForm)">

      <div formGroupName="Survey">
        <input type="hidden" name="Id" formControlName="Id">
        <label>{{model.Survey.Name}}</label>
      </div>

      <div class='qa-set' formArrayName="QuestionAnswerSets">
        <fieldset *ngFor="let questionAnswerSet of surveyForm.controls.QuestionAnswerSets.controls; index as setId;" [formGroupName]="setId">
          <div formGroupName="Question">

            <input type="hidden" name="Id" formControlName="Id">
            <label>{{setId+1}}. </label>
            <label>{{model.QuestionAnswerSets[setId].Question.Value}}</label>
          </div>

          <div class="row" formArrayName="Answers">
            <div *ngFor="let answer of this.surveyForm.controls.QuestionAnswerSets.controls[setId].controls.Answers.controls; index as answerId;"
              [formGroupName]="answerId">

              <div class="col-12 col-sm-3" formGroupName="Answer">
                <input …
Run Code Online (Sandbox Code Playgroud)

angular6

6
推荐指数
1
解决办法
2106
查看次数

windows 防火墙规则有优先级吗

我们是否可以手动或以编程方式更改或优先选择一个 Windows 防火墙规则而不是其他规则?

实际上,我添加了一条防火墙规则来阻止所有出站流量。然后,我又添加了一个与应用程序相关的防火墙出站规则,我可以在出站规则列表中看到它,但所有流量仍然被阻止,因此我无法验证通过代码添加的允许出站流量规则是否正常工作或不是?知道我们是否可以优先选择其中之一吗?

windows-firewall

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

Angular 7 到 dotnetcore 2.1 web api 调用没有响应

下面是来自 login.component.ts 的代码,

login() {
const val = this.form.value;

if (val.email && val.password) {
  this.authService.login(val.email, val.password)
    .subscribe(
      data => {

        if (data && data.Token) {
          // store user details and jwt token in local storage to keep user logged in 
          //between page refreshes
          localStorage.setItem('currentUser', JSON.stringify(data));
          console.log("user logged in");
          this.router.navigate([this.returnUrl]);
        } else {
          console.log("user not logged in");
        }

      },
      error => {
        this.error = error;
      });
 }
}
Run Code Online (Sandbox Code Playgroud)

下面是角度服务的代码,

login(email: string, password: string) {
 return this.http.post<User>(this.baseUrl + "Authenticate", { email, 
password …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-webapi angular asp.net-core-2.1 angular7

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