我正在用 webdriver.io 编写自动化测试。我正在使用 grunt/babelify/browserify 以便我可以在 ES6 中编写测试。我的脚本中需要一些节点模块。我希望能够不将这些节点文件编译到我的分发脚本中,而只是按原样打印出 require 语句,因为我仍在运行脚本服务器端。换句话说,有没有办法用browserify“按原样”继承代码?以下是我需要的模块:
required libraries
var webdriverio = require('webdriverio');
var chai = require("chai");
chai.config.includeStack = true; // prints out full call stack
var expect = chai.expect;
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
这是我的咕噜声文件:
module.exports = function (grunt) {
grunt.initConfig({
browserify: {
dist: {
options: {
transform: [
["babelify", {
loose: "all"
}]
]
},
files: {
// if the source file has an extension of es6 then
// we change the name of the source file accordingly.
// The result file's extension is always .js
"./dist/module.js": ["./modules/*"]
}
}
},
watch: {
scripts: {
files: ["./modules/*/*.js"],
tasks: ["browserify"]
}
}
});
grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.registerTask("watch", ["watch"]);
grunt.registerTask("build", ["browserify"]);
};