无法获取 .js 文件路径

Cannot get the .js file route

无法使用 Minium Developer 获取 .js 文件。我有示例项目中的路线,但它不起作用。我做错了什么?

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");
  }

});

项目层次结构

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

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

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

您必须从要求路径中排除 "modules" 文件夹:

require("Helper/Helper");

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