Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

enum not recognised - cypress angular unit test

I have been trying to implement cypress-angular-unit-test into my existing Angular 9 app.

I have been getting this issue which I'm not sure how to fix. I keep getting this issue in a file that is totally unrelated to my test case.

It seems to think that the Enum is undefined, however we can clearly see that it is not. Also during testing of the app in that area, everything works as expected

also my component and cy-spec.ts files are very simple

any idea why I keep getting this error?I have spent a long time trying to find an answer...

// cy-spec.ts
describe('KitLabelComponent', () => {
  beforeEach(() => {
    initEnv(KitLabelComponent, {
      declarations: [HelptipComponent],
    });
  });
  it('shows label with tooltip', () => {
    mount(KitLabelComponent, {
      label: 'test label',
      tooltipText: 'test tooltip',
    });
    cy.contains('test label');
  });
});

/// component.ts
import { Component, Input } from '@angular/core';
@Component({
  selector: 'kit-label',
  template: `
    <label>
      <div>
        <span
          >{{ label }}
          <app-helptip *ngIf="tooltipText" [titleText]="label" [contentText]="tooltipText"></app-helptip>
        </span>
      </div>
      <ng-content></ng-content>
    </label>
  `,
  styleUrls: ['./kit-label.component.less'],
})
export class KitLabelComponent {
  @Input() label: string;
  @Input() tooltipText: string;
}

enter image description here enter image description here

question from:https://stackoverflow.com/questions/65661551/enum-not-recognised-cypress-angular-unit-test

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...