我正在测试角度和JHipster的应用程序。
我尝试测试这样的标签:
<label #hiddenLabel class="form-control-label" jhiTranslate="oncosupApp.paciente.nombre" for="field_nombre" >Nombre</label>
它给出了隐藏未定义的错误,这意味着它不会引用HTML元素。
然后我尝试没有像这样的jhiTranslate:
<label #hiddenLabel class="form-control-label" for="field_nombre" >Nombre</label>
一切都很完美。 testBed代码在这里,我还没有包含jhi的任何翻译功能,因为我是JHI的新手并且不知道要插入什么:
imports.....
describe('Component Tests', () => {
describe('Paciente Management Dialog Component', () => {
let comp: PacienteDialogComponent;
let fixture: ComponentFixture<PacienteDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [OncosupTestModule,
OncosupSharedModule,
BrowserModule,
FormsModule,
],
declarations: [PacienteDialogComponent,
],
providers: [
JhiAlertService, ],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
//.overrideTemplate(PacienteDialogComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PacienteDialogComponent);
comp = fixture.componentInstance;
//service = fixture.debugElement.injector.get(PacienteService);
//mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
//mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
fit ('first test asdsadfdfd', async(() => {
expect(comp.hidden.nativeElement.innerHTML).toContain('Nombre');
}));
&#13;
我的组件:
imports...
@Component({
selector: 'jhi-paciente-dialog',
template: require('./paciente-dialog.component.html'),
styleUrls: [
'paciente.css'
],
})
export class PacienteDialogComponent implements OnInit {
@ViewChild('hiddenLabel') hidden: ElementRef;
&#13;
这意味着jhiTranslate不允许我参考HTML元素。我怎样才能解决这个问题?我无法删除jhiTranslate,因为该应用程序不是我的。我只需要测试它。