Javascript 由于模块导出,量角器代码失败
在我的量角器框架中,我使用的是POM模型,因此许多代码驻留在不同的Javascript 由于模块导出,量角器代码失败,javascript,angular,protractor,e2e-testing,Javascript,Angular,Protractor,E2e Testing,在我的量角器框架中,我使用的是POM模型,因此许多代码驻留在不同的.js文件中,然后在必要的连接处调用这些文件以进行e2e测试 我有一个CompleteProfile.js文件(虚拟名称),其中有一个条件 if profile_flag ===100, then do nothing else complete profile (includes a lot of forms) 对于else部分,我将代码放在不同的fillCustomerForms.js文件中,其代码如下所示 va
.js
文件中,然后在必要的连接处调用这些文件以进行e2e测试
我有一个CompleteProfile.js
文件(虚拟名称),其中有一个条件
if profile_flag ===100,
then do nothing
else
complete profile (includes a lot of forms)
对于else
部分,我将代码放在不同的fillCustomerForms.js
文件中,其代码如下所示
var completeprofile = function(){
this.locator = element(by.css('some_css_locator'));
this.locator.click();
browser.sleep(2000);
}
module.exports={
profileComplete1 = completeprofile
}
我在我的CompleteProfile.js
中使用了fillCustomerPerforms.js
中的这个
var Profile = require('./fillCustomerForms.js');
var c_profile = new Profile.profileComplete1();
var compl_profile = function(){
this.someFunction= function(){
profile_flag = "90"
if profile_flag ==="100"{
then do nothing;
}else{
c_profile.completeprofile();
}
}
}
module.exports={
finalExp = compl_profile
}
var Profile = require('./CompleteProfile.js');
var co_profile = new Profile.finalExp();
describe("Modules",()=>{
it('Modules that load other things',()=>{
//do other things neccessary
});
});
describe("Module",()=>{
it("should do something,"()=>{
co_profile.someFunction();
});
});
在我的spec.js
中,我将CompleteProfile.js
称为
var Profile = require('./fillCustomerForms.js');
var c_profile = new Profile.profileComplete1();
var compl_profile = function(){
this.someFunction= function(){
profile_flag = "90"
if profile_flag ==="100"{
then do nothing;
}else{
c_profile.completeprofile();
}
}
}
module.exports={
finalExp = compl_profile
}
var Profile = require('./CompleteProfile.js');
var co_profile = new Profile.finalExp();
describe("Modules",()=>{
it('Modules that load other things',()=>{
//do other things neccessary
});
});
describe("Module",()=>{
it("should do something,"()=>{
co_profile.someFunction();
});
});
第一个descripe
块是加载浏览器并检查URL和其他测试用例的块。我的问题是,如果我添加第二个descripe
块,那么在第一个descripe
块中发送的URL将呈现为空,即Chrome加载时没有任何URL,并且由于超时错误而出错。我已经检查了代码,看起来还可以。我做错了什么
我猜这可能与JS的一些基础知识有关,我可能忽略了这些,但现在我无法理解这一点 您的第二个测试用例中有语法错误(函数
it
)。Mocha中每个测试用例的每次回调都需要解决或拒绝。e、 g:
it('should ...', done => {
/* assertion */
done(/* passing a new instance of Error will reject the testcase*/);
});`.
被调用的函数在提供的代码段中不返回任何内容,我真的看不出您要测试什么。测试使用的是
Jasmine 2.0
framework,而不是Mocha,因此语法在这里不是问题。