无法获取.js文件路由

时间:2018-07-23 10:26:03

标签: javascript cucumber

无法通过Minium Developer获取.js文件。我有类似于示例proyect的路线,但是它不起作用。我在做什么错了?

Helper.js

var helperFuntions = {

findExistingDataOnTable : function(cssSelector,query){

    var encontrado = $(cssSelector).matchingText(query);

    if (encontrado) {

        console.log("Superado");
    }else{

      console.log("No superado");
    }

  }

};

ProyectoPrueba.js(无效,导入错误)

var helperFuntions = require("modules/Helper/Helper.js");

When(/^Compruebo la existencia de "(.*?)"$/, function (query) {
   var cssTable = "\".ym-cbox\"";

helperFuntions.findExistingDataOnTable(cssTable, query);

});

ProyectoPrueba.js(正常运行,未导入)

When(/^Compruebo la existencia de "(.*?)"$/, function (query) {

    var found= $(".ym-cbox").matchingText(query);
  if (found) {
    console.log("Superado");

  }else{
    console.log("No superado");
  }

});

保护等级

Proyect hierarchy

2 个答案:

答案 0 :(得分:2)

您必须从要求路径中排除“模块”文件夹:

  

require(“ Helper / Helper”);

此外,不需要扩展名“ .js”。

答案 1 :(得分:-1)

除非您要从node_modules文件夹中导入模块,否则您的导入必须是绝对路径。

假设modules文件夹是您要从中导入当前文件夹的同级文件。

在这种情况下,require("modules/Helper/Helper.js");应该是require("../modules/Helper/Helper.js");

相关问题