jjzjj

integration-testing

全部标签

Javascript : onHashchange Test

我正在尝试检查浏览器是否支持onHashChange或者如果不支持则不隐藏一些代码,以这种方式:if(window.onhashchange){...code...}else{...othercode...}我也试过这个:if(typeofwindow.onhashchange==="function"){alert("Supports");}else{alert("Doesn'tSupports");}如Quirksmode所述这应该有效,但是如果我在Safari中的truestate中执行alert比提醒我但Safari不支持onHashChange:S它有什么问题?如果我走的路不

javascript - Angular Directive(指令) : It's possible testing that certain characters are rejected in a keypress event?

我一直在构建一个指令来限制用户按下某些无效字符,在这种情况下,使用keypress事件绑定(bind)到使用我的指令的输入元素。我一直在尝试测试此功能,但我不明白如何实现。我的指令angular.module('gp.rutValidator').directive('gpRutValidator',directive);directive.$inject=['$filter'];functiondirective($filter){varddo={restrict:'A',require:'ngModel',link:linkFn};returnddo;functionlinkFn(

javascript - 如何使用 vue-test-utils 测试 CSS 框架自定义组件

我使用的是BuefyCSS框架,它提供自定义vue-js组件,例如和,我在测试时遇到了问题标签。import{shallowMount,createLocalVue}from'@vue/test-utils'importBInputPracticefrom'../BInputPractice.vue'importBuefyfrom'buefy'constlocalVue=createLocalVue()localVue.use(Buefy)describe('b-inputPractice',()=>{it('updatesthenamedataproperty',()=>{const

javascript - 模拟 node.js 模块

假设我有这种情况(架构)layer1->layer2->layer3层只是普通的node.js模块(有一些导出的函数)Layer1需要layer2并调用他的函数,layer2需要layer3并调用他的函数。我想测试第1层中的函数,但也模拟第3层(我在第1层中的函数调用传播到第3层,我想模拟这个函数)。最好的方法是什么?我看过这个模块:https://github.com/thlorenz/proxyquire但我认为它不支持像我的示例那样深入到2级或更高级别时进行模拟。感谢您的任何建议! 最佳答案 我用过mockery取得了巨大的成

javascript - 如何将 Jest 中的 '__mocks__' 文件夹移动到/test?

我已经开始在Jest中使用mocks来测试我的NodeJS应用程序并且它们工作得很好,但是将__mocks__文件夹移动到/test文件夹会更有意义所以与测试相关的所有内容都在那里,而不是在/src中混合文件。这在某种程度上是可能的吗?我在Jest文档中的任何地方都找不到它。 最佳答案 jest.mock('../src/service',()=>require('./__mocks__/request'));这对我有用 关于javascript-如何将Jest中的'__mocks__'

javascript - Angular Testing 错误 - NullInjectorError : No provider for TrimInputDirective

我创建了一个Angular指令,它使用CSS选择器自动trim我的应用程序中的输入,它看起来像这样......import{Directive,HostListener,forwardRef}from'@angular/core';import{DefaultValueAccessor,NG_VALUE_ACCESSOR}from'@angular/forms';exportconstTRIM_VALUE_ACCESSOR:any={provide:NG_VALUE_ACCESSOR,useExisting:forwardRef(()=>TrimInputDirective),mult

javascript - react / enzyme : How to test for subcomponent?

这就是我的Messenger组件的样子。如您所见,有一个主要组件和一个列表组件。主要组件默认导出。有了这个,我的应用程序中的一切都按预期工作。/imports/ui/components/messenger.jsximportReact,{Component}from'react'importPropTypesfrom'prop-types'import{Container,Segment,Loader,Header}from'semantic-ui-react'classMessengerextendsComponent{staticgetpropTypes(){return{dat

javascript - 为什么 RegEx.test 会在后续调用中更改结果?

这个问题在这里已经有了答案:WhydoesaRegExpwithglobalflaggivewrongresults?(7个答案)关闭7年前。为什么以下从true变为false;varr=/e/gi;r.test('e');//truer.test('e');//false然后继续切换true,false,true,false......

javascript - Regex.test() 给出真假顺序?

任何人都可以解释一下,为什么本地Regex变量和非本地Regex变量有不同的输出。varregex1=/a|b/g;functionisAB1(){returnregex1.test('a');}console.log(isAB1());//trueconsole.log(isAB1());//falseconsole.log(isAB1());//trueconsole.log(isAB1());//falsefunctionisAB2(){varregex2=/a|b/g;returnregex2.test('a');}console.log(isAB2());//truecons

javascript - andThen 和 click 助手的 Ember.JS 集成测试问题

我在使用Ember的测试助手时得到了奇怪的结果andThen和click.根据Ember的documentation:theandThenhelperwillwaitforallprecedingasynchronoushelperstocompletepriortoprogressingforward.但是,我发现情况似乎并非总是如此。在下面的示例中,有3个console.debug声明。我希望它们按A->B->C的顺序记录。但我一直得到这个顺序:A->C->B。当我只使用两次点击中的一次时,我只能获得预期的ABC顺序helper。没有与关联的事件监听器(操作)点击助手中引用的元素。