本文介绍了Angular6茉莉花TypeError:期望(...).toBeVisible不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在angular6中设置茉莉查询匹配
Setting up jasmine-query-matches in angular6
在angular 5项目上,它看起来很简单
On angular 5 project it looks at simple as
import { } from 'jasmine-jquery/lib/jasmine-jquery';
import { } from 'jasmine-jquery-matchers';
import * as $ from 'jquery';
在角度6上,我尝试了以下方法
On angular 6 i have tried the following
import {} from "jasmine-jquery/lib/jasmine-jquery" ;
import {} from "jasmine-jquery-matchers/dist/jasmine-jquery-matchers" ;
import { } from "karma-jasmine-jquery";
import * as $ from 'jquery';
或
import {} from "jasmine-jquery" ;
import {} from "jasmine-jquery-matchers" ;
import { } from "karma-jasmine-jquery";
import * as $ from 'jquery';
用法如下
imagesEL = fixture.debugElement.query(By.css('.cycle'));
和
expect(imagesEL).toBeVisible();
或
expect(imagesEL.nativeElement).toBeVisible();
但是每件事似乎都给出了相同的错误
But every thing seems to be giving the same error
感谢您的帮助
示例代码:https://stackblitz.com/edit/ng-test-tobevisible?file=app/hello.component.spec.ts
推荐答案
尝试将其用作导入
import "jasmine-jquery/lib/jasmine-jquery" ;
import "jasmine-jquery-matchers/dist/jasmine-jquery-matchers" ;
import "karma-jasmine-jquery";
import 'jquery';
请注意,jasmine-jquery-matchers没有默认导出
Please note that jasmine-jquery-matchers does not have a default export
这篇关于Angular6茉莉花TypeError:期望(...).toBeVisible不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!