Bam*_*mbi 0 angular cypress nrwl cypress-component-test-runner
我现在真的很困惑,不知道该怎么办。
Cypress 似乎可以接受明显失败的测试,而且不会执行,cy.wait(10000);正如您在图像右上角的时间戳中看到的那样。
我在 nx Angular 项目中构建了 Cypress 组件测试。这是测试和输出,我做错了什么?
毕竟部分是因为有插件而存在的,没有它也有同样的行为。
/// <reference types="cypress" />
import { MatDialogRef } from "@angular/material/dialog";
import { CreateDiscussionPopUpComponent } from "./create-discussion-pop-up.component";
import { NO_ERRORS_SCHEMA } from "@angular/core";
import { MatInputModule } from "@angular/material/input";
import { SharedUtilitiesModule, MaterialModule } from "@xxx/shared-utilities";
import {
TranslateLoader,
TranslateModule,
TranslateService,
} from "@ngx-translate/core";
import {
TranslateLoaderMock,
TranslateServiceTestProvider,
} from "@xxx/shared-services/mocks";
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { FlexLayoutModule } from "@angular/flex-layout";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
const config = {
imports: [
TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: TranslateLoaderMock },
}),
FormsModule,
BrowserAnimationsModule,
ReactiveFormsModule,
SharedUtilitiesModule,
MaterialModule,
MatInputModule,
FlexLayoutModule,
],
declarations: [CreateDiscussionPopUpComponent],
providers: [
{
provide: MatDialogRef,
useValue: {},
},
TranslateServiceTestProvider,
],
schemas: [NO_ERRORS_SCHEMA],
};
describe("ISO-Akzeptanz-Test der CreateDiscussionPopUpComponent-Komponente", () => {
let component: CreateDiscussionPopUpComponent;
let fixture: ComponentFixture<CreateDiscussionPopUpComponent>;
beforeEach((done) => {
cy.viewport(750, 300);
cy.mount(CreateDiscussionPopUpComponent, config).then((res) => {
component = res.component;
fixture = res.fixture;
console.log(component + " " + fixture);
const translateService = TestBed.inject(TranslateService);
translateService.use("de");
done();
});
});
describe("ISO 171", () => {
it("8.1.3", () => {
cy.wait(10000);
expect(false).to.equal(true);
});
});
});
Run Code Online (Sandbox Code Playgroud)
预先感谢您的任何帮助!^^
您将能够使用 Cypress 命令执行等待和期望。
要么将期望包装在.then()回调中,要么将其转换为 Cypress.should()
describe("ISO 171", () => {
it("8.1.3", () => {
cy.wait(10_000);
cy.then(() => expect(false).to.equal(true))
})
Run Code Online (Sandbox Code Playgroud)
或者
describe("ISO 171", () => {
it("8.1.3", () => {
cy.wait(10_000);
cy.wrap(false).should(`equal`, true)
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
584 次 |
| 最近记录: |