Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何在Cypress Component Test Runner中安装角度组件_Angular_Cypress - Fatal编程技术网

Angular 如何在Cypress Component Test Runner中安装角度组件

Angular 如何在Cypress Component Test Runner中安装角度组件,angular,cypress,Angular,Cypress,我尝试在Angular中的新设置Cypress Component Test Runner环境中安装Angular组件,如下所示: import { ɵrenderComponent as renderComponent, ɵcompileComponent as compileComponent} from '@angular/core'; import '@angular/compiler'; import 'zone.js'; import { UT1DashEmployeesCompon

我尝试在Angular中的新设置Cypress Component Test Runner环境中安装Angular组件,如下所示:

import { ɵrenderComponent as renderComponent, ɵcompileComponent as compileComponent} from '@angular/core';
import '@angular/compiler';
import 'zone.js';
import { UT1DashEmployeesComponent } from './ut1-dash-employees.component';

/* eslint-env mocha */
/* global cy */
describe('UT1DashEmployeesComponent', () => {
  beforeEach(() => {
    const html = `
      <head>
        <meta charset="UTF-8">
      </head>
      <body>
        <app-ut1-dash-employees></app-ut1-dash-employees>
      </body>
    `;
    const document = (cy as any).state('document');
    document.write(html);
    document.close();

    // Quick hack to get the component definition, which in our case is the first annotation.
    compileComponent(UT1DashEmployeesComponent, (<any>UT1DashEmployeesComponent).__annotations__[0]);
    renderComponent(UT1DashEmployeesComponent, {
      host: document.body
    });
  });

  it('works', () => {
    cy.contains('UT1DashEmployeesComponent!').should('be.visible');
  });

  it('works again', () => {
    cy.contains('UT1DashEmployeesComponent').should('be.visible');
  });

});
从'@angular/core'导入{renderComponent作为renderComponent,ɵcompileComponent作为compileComponent};
导入“@angular/compiler”;
导入'zone.js';
从“./ut1 dash employees.component”导入{UT1DashEmployeesComponent};
/*埃斯林特环境摩卡酒店*/
/*全球cy*/
描述('UT1DashEmployeesComponent',()=>{
在每个之前(()=>{
常量html=`
`;
const document=(如有)。state(“document”);
document.write(html);
document.close();
//快速获得组件定义,在我们的例子中,这是第一个注释。
compileComponent(UT1DashEmployeesComponent,(UT1DashEmployeesComponent)。uu注释_u[0]);
渲染组件(UT1DASHEMPLOYEES组件{
主持人:document.body
});
});
它('有效',()=>{
cy.contains('UT1DashEmployeesComponent!')。应('be.visible');
});
它('再次工作',()=>{
cy.contains('UT1DashEmployeesComponent')。应('be.visible');
});
});
但我得到以下错误:

错误 未解析组件“UT1DashEmployeesComponent”:

  • templateUrl:./ut1-dash-employees.component.pug
  • 样式URL:[“/ut1 dash employees.component.styl”] 是否运行并等待“resolveComponentResources()”
由于此错误发生在每次挂钩之前的测试期间,因此我们将跳过当前套件中的其余测试:UT1DashEmployeesComponent

我能做什么