在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):knpwrs/gulp-spawn-mocha开源软件地址(OpenSource Url):https://github.com/knpwrs/gulp-spawn-mocha开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-spawn-mochaThis is a plugin for gulp which runs Mocha tests in a separate process from
the UsageUsage is according to this API: stream.pipe(
mocha({
// options
})
); This plugin uses The plugin accepts these special options:
All other options are properly prefixed with either const DEBUG = process.env.NODE_ENV === "debug",
CI = process.env.CI === "true";
var gulp = require("gulp"),
mocha = require("./lib");
gulp.task("test", function() {
return gulp.src(["test/*.test.js"], { read: false }).pipe(
mocha({
debugBrk: DEBUG,
r: "test/setup.js",
R: CI ? "spec" : "nyan",
istanbul: !DEBUG
})
);
});
gulp.task("default", ["test"], function() {
gulp.watch("{lib,test}/*", ["test"]);
}); With this setup the The Conditional ArgumentsIf the value of an argument is falsy (but not const DEBUG = process.env.NODE_ENV === "debug";
stream.pipe(
mocha({
debugBrk: DEBUG,
istanbul: !DEBUG
})
); Custom Environment VariablesAs mentioned above an object provided underneath the var gulp = require("gulp"),
mocha = require("gulp-spawn-mocha");
gulp.task("test", function() {
return gulp.src(["test/*.test.js"]).pipe(
mocha({
env: { NODE_ENV: "test" }
})
);
}); These variables are merged with your current environment variables and sent to the mocha executable. Code CoverageBecause of the nature of this plugin launching an external process to run tests,
the standard coverage plugins for gulp will not work with this module. Starting
in version Set gulp.task("test", function() {
return gulp.src(["test/*.test.js"]).pipe(
mocha({
istanbul: true
})
);
}); This will launch a process equivilant to:
The default settings of Istanbul output to a directory in the If you want to pass options to Istanbul, you can do that as well: gulp.task("test", function() {
return gulp.src(["test/*.test.js"]).pipe(
mocha({
istanbul: {
dir: "path/to/custom/output/directory"
}
})
);
}); This will launch a process equivilant to:
This will output to a directory called Istanbul, like gulp.task("test", function() {
return gulp.src(["test/*.test.js"]).pipe(
mocha({
istanbul: {
dir: "path/to/custom/output/directory",
bin: require.resolve("isparta") + "/bin/isparta"
}
})
);
}); This will launch a process equivilant to:
Publishing Coverage ReportsAssuming you are using Travis for CI and Coveralls for
publishing code coverage reports it is very easy to automatically have Travis
publish to Coveralls when tests are run successfully. First make sure you
install and save the
Then edit your language: node_js
node_js:
- "0.11"
- "0.10"
after_success: ./node_modules/.bin/coveralls --verbose < coverage/lcov.info The Output Reports to a FileYou can pass Use file path: gulp.task("test", function() {
return gulp.src(["test/*.test.js"], { read: false }).pipe(
mocha({
debugBrk: DEBUG,
r: "test/setup.js",
R: CI ? "spec" : "nyan",
istanbul: !DEBUG,
output: "result.log"
})
);
}); Use file stream: gulp.task("test", function() {
return gulp.src(["test/*.test.js"], { read: false }).pipe(
mocha({
debugBrk: DEBUG,
r: "test/setup.js",
R: CI ? "spec" : "nyan",
istanbul: !DEBUG,
output: fs.createWriteStream("result.log", { flags: "w" })
})
);
});
This or |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论