Angular6 Jasmine TypeError:expect(...).toBeVisible 不是函数 [英] Angular6 Jasmine TypeError: expect(...).toBeVisible is not a function

查看:24
本文介绍了Angular6 Jasmine TypeError:expect(...).toBeVisible 不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 angular6 中设置 jasmine-query-matches

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';

在 angular 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

TypeError: expect(...).toBeVisible 不是函数

TypeError: expect(...).toBeVisible is not a function

感谢您的帮助

示例代码: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 Jasmine TypeError:expect(...).toBeVisible 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆