如何编写角度8形式的单元测试用例,即ElementRef.nativeelement.submit()

时间:2020-02-27 06:48:57

标签: angular jasmine angular8

我正在尝试为茉莉花编写8号单元测试用例。我的表格如下:

<form ngNoForm method="post" [action]="url" name="redirect" #redirectForm>
    <input  type= "hidden" name="mesgFromBank" value="{{message}}">
  </form>

我的ts文件看起来像这样:

@ViewChild('redirectForm', { read: ElementRef, static: false }) redirectForm: ElementRef;

 this.redirectForm.nativeElement.action = this.url;
 this.redirectForm.nativeElement.firstChild.value = this.message;
 this.redirectForm.nativeElement.submit();

但是,我尝试编写测试用例时,它将重定向到this.url并最终崩溃,并且在浏览器的Karma运行程序中看到"NOT FOUND"

有人可以帮我吗?

谢谢。

0 个答案:

没有答案
相关问题