据我了解,angular-cli默认情况下会.spec为我们通过它创建的任何组件创建一个文件。.spec但是,如果误删除了一个文件,有可能只生成该文件。
我尝试了一些建议 -
ng g c <component_name> --spec-only但它不起作用。
注意 - 不使用任何其他 npm 模块(如果可用)。
一旦收到后端响应,下拉菜单基本上需要很长时间才能加载。如果我等待大约 8 秒,那么它就起作用了。但是,不想在这里硬编码等待。知道可能会出什么问题吗?我也无法识别css。
cy.get('input').last().type(`{selectall}${value}`);
cy.get('mat-option > span').then(option => {
if (option.get(0).textContent === 'Loading...') {
cy.wait(5000);
}
});
cy.containsCaseInsensitive(value, 'mat-option').first().scrollIntoView().debug().click();
Run Code Online (Sandbox Code Playgroud)
错误日志——
CypressError: Timed out retrying: cy.click() failed because this element is detached from the DOM.
<mat-option _ngcontent-gcj-c21="" class="mat-option ng-star-inserted" role="option" ng-reflect-value="[object Object]" tabindex="0" id="mat-option-104" aria-disabled="false" style="">...</mat-option>
Cypress requires elements be attached in the DOM to interact with them.
The previous command that ran was:
> cy.debug()
This DOM element likely became detached somewhere between the previous and current command.
Common situations …Run Code Online (Sandbox Code Playgroud) 我尝试了几个命令,但似乎没有任何效果。它要么逃脱所有,要么不运行。
@TestFeature
Feature: Test Feature
Testing sample feature
Background: Logging in
@manual
Scenario: A
Given
Scenario Outline: B
Run Code Online (Sandbox Code Playgroud)
我想运行Test Feature并跳过标记的场景manual。我试过 -
npx cypress run --env TAGS=@TestFeature and not @manual --browser chrome
Run Code Online (Sandbox Code Playgroud)
但这不起作用。也尝试过类似的组合,但没有效果。
我是新手nestjs,正在尝试将我的后端从 转换nodejs为nestjs. 希望这是有道理的吗?我正在使用`typeorm. 但我不确定捕获错误的最佳方法是什么。
entity.ts
import { Entity, Column, PrimaryGeneratedColumn, PrimaryColumn } from 'typeorm';
@Entity()
export class Course {
@PrimaryColumn()
course: string;
@Column("varchar", { array: true })
subject: string[];
}
Run Code Online (Sandbox Code Playgroud)
controller.ts
import { Controller, Get, Post, Body } from '@nestjs/common';
import { CourseService } from './course.service';
import { Course } from './course.entity';
@Controller('course')
export class CourseController {
constructor(private courseService: CourseService) {}
@Get()
getCourses(): Promise<Course[]> {
return this.courseService.findAll();
}
@Post()
addCourse(@Body() courseDto: Course[]) {
return …Run Code Online (Sandbox Code Playgroud) 当我尝试到达任何端点时,我在 IDE 控制台中看不到任何状态或控制台消息。我确实看到返回了响应,但控制台中没有呼叫详细信息。我很困惑为什么它会这样?
以下是我跑步时看到的情况npm run-script start:dev——
> nest start --watch
[3:04:44 PM] Starting compilation in watch mode...
[Nest] 14340 - 05/20/2020, 3:10:58 PM [NestFactory] Starting Nest application...
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] TypeOrmModule dependencies initialized +220ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] TypeOrmCoreModule dependencies initialized +195ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] TypeOrmModule dependencies initialized +6ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] AppModule dependencies initialized +5ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RoutesResolver] …Run Code Online (Sandbox Code Playgroud) 我需要在 Angular 中测试一个组件,它只有一种方法和某些 @Input 和 @Output 属性-
updateColumns(eventValue: ManagedColumns) {
this.applyColumnChanges.emit(eventValue);
}
Run Code Online (Sandbox Code Playgroud)
还有另一个组件具有应该调用上述方法的方法。调用因为它正在发出一个事件,我相信该事件将被另一个事件消耗,而后者又会发出另一个事件,该事件被另一个组件中的第三个消耗 -
applyChanges() {
this.apply.emit(<ManagedColumns>{
selectedColumns: this.selectedItems.slice(),
availableColumns: this.availableItems.slice()
});
this.closeDialog();
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试测试 updateColumns 但不知道该怎么做?是否可以模拟 applyChanges 依次发送到 updateColumns 并且我们可以检查相同的值?
如果我试过——
manageColumnsComponent = TestBed.createComponent(ManageColumnsComponent).componentInstance;
spyOn(manageColumnsComponent.applyChanges, 'emit');
Run Code Online (Sandbox Code Playgroud)
得到错误 -
[ts] Argument of type '"emit"' is not assignable to parameter of type 'never'.
Run Code Online (Sandbox Code Playgroud) 我在一个页面上有多个自动完成功能,可以选择值并保存它们。我需要的是,当我下次加载页面时,默认情况下应该为已经选择和保存的值显示预先选择的值。
以下是代码片段-
<ng-container matColumnDef="course">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Course Section </th>
<td mat-cell *matCellDef="let course"> {{course.courseSection}}
<mat-form-field>
<input type="text" id="{{course.courseSection}}" placeholder="Pick one" aria-label="Number" matInput [formControl]="myControl"
[matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="onSelectionChanged(course.courseSection, $event)">
<mat-option *ngFor="let option of filteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</td>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
在 ngOnInit 上,我能够获取保存在地图中的值,并且使用了以下不起作用的逻辑 -
checkAssigned(section: string) {
if (this.assigned.has(section)) {
return this.assigned.get(section);
} else {
return '';
}
}
Run Code Online (Sandbox Code Playgroud)
html -
<mat-option *ngFor="let option of filteredOptions | async"
[value]="checkAssigned(course.courseSection)===''? option : checkAssigned(course.courseSection)">
Run Code Online (Sandbox Code Playgroud)
但它不起作用。关于如何实现它的任何建议?