gulp-mocha
Advanced tools
Comparing version 2.2.0 to 3.0.0
10
index.js
'use strict'; | ||
var domain = require('domain'); | ||
var domain = require('domain'); // eslint-disable-line no-restricted-modules | ||
var gutil = require('gulp-util'); | ||
@@ -7,3 +7,3 @@ var through = require('through'); | ||
var plur = require('plur'); | ||
var resolveFrom = require('resolve-from'); | ||
var reqCwd = require('req-cwd'); | ||
@@ -16,3 +16,3 @@ module.exports = function (opts) { | ||
for (var key in require.cache) { | ||
for (var key in require.cache) { // eslint-disable-line guard-for-in | ||
cache[key] = true; | ||
@@ -31,3 +31,3 @@ } | ||
opts.require.forEach(function (x) { | ||
require(resolveFrom(process.cwd(), x)); | ||
reqCwd(x); | ||
}); | ||
@@ -45,3 +45,3 @@ } | ||
function handleException(err) { | ||
if (err.name === 'AssertionError' && runner) { | ||
if (runner) { | ||
runner.uncaught(err); | ||
@@ -48,0 +48,0 @@ } else { |
{ | ||
"name": "gulp-mocha", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Run Mocha tests", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "xo && mocha" | ||
}, | ||
@@ -38,8 +38,17 @@ "files": [ | ||
"gulp-util": "^3.0.0", | ||
"mocha": "^2.0.1", | ||
"mocha": "^3.0.0", | ||
"plur": "^2.1.0", | ||
"resolve-from": "^1.0.0", | ||
"req-cwd": "^1.0.1", | ||
"temp": "^0.8.3", | ||
"through": "^2.3.4" | ||
}, | ||
"devDependencies": { | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"envs": [ | ||
"node", | ||
"mocha" | ||
] | ||
} | ||
} |
# gulp-mocha [![Build Status](https://travis-ci.org/sindresorhus/gulp-mocha.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-mocha) | ||
> Run [Mocha](https://github.com/mochajs/mocha/) tests | ||
> Run [Mocha](https://github.com/mochajs/mocha) tests | ||
*Keep in mind that this is just a thin wrapper around Mocha and your issue is most likely with Mocha.* | ||
**[Maintainer needed](https://github.com/sindresorhus/gulp-mocha/issues/128)** | ||
## Install | ||
@@ -18,13 +20,15 @@ | ||
```js | ||
var gulp = require('gulp'); | ||
var mocha = require('gulp-mocha'); | ||
const gulp = require('gulp'); | ||
const mocha = require('gulp-mocha'); | ||
gulp.task('default', function () { | ||
return gulp.src('test.js', {read: false}) | ||
gulp.task('default', () => | ||
gulp.src('test.js', {read: false}) | ||
// gulp-mocha needs filepaths so you can't have any plugins before it | ||
.pipe(mocha({reporter: 'nyan'})); | ||
}); | ||
.pipe(mocha({reporter: 'nyan'})) | ||
); | ||
``` | ||
> If you are writing a watch task to run your tests as you modify your `.js` files, be aware that you might run into issues. This plugin runs your Mocha tests within the same process as your watch task and state isn't reset between runs. If your tests eventually fail within the watch task but pass when run in a standalone task or with `mocha test`, then you need to use the [`gulp-spawn-mocha`](https://github.com/KenPowers/gulp-spawn-mocha) plugin. | ||
## API | ||
@@ -38,21 +42,21 @@ | ||
Type: `string` | ||
Default: `bdd` | ||
Values: `bdd`, `tdd`, `qunit`, `exports` | ||
Type: `string`<br> | ||
Default: `bdd`<br> | ||
Values: `bdd` `tdd` `qunit` `exports` | ||
The interface to use. | ||
Interface to use. | ||
##### reporter | ||
Type: `string` | ||
Default: `spec` | `dot` prior to mocha v1.21.0 | ||
Values: [reporters](https://github.com/mochajs/mocha/tree/master/lib/reporters) | ||
Type: `string`<br> | ||
Default: `spec` | ||
Values: [Reporters](https://github.com/mochajs/mocha/tree/master/lib/reporters) | ||
The reporter that will be used. | ||
Reporter that will be used. | ||
This option can also be used to utilize third-party reporters. For example if you `npm install mocha-lcov-reporter` you can then do use `mocha-lcov-reporter` as value. | ||
This option can also be used to utilize third-party reporters. For example, if you `npm install mocha-lcov-reporter` you can then do use `mocha-lcov-reporter` as value. | ||
##### globals | ||
Type: `array` | ||
Type: `Array` | ||
@@ -63,3 +67,3 @@ List of accepted global variable names, example `['YUI']`. Accepts wildcards to match multiple global variables, e.g. `['gulp*']` or even `['*']`. See [Mocha globals option](http://mochajs.org/#globals-option). | ||
Type: `number` | ||
Type: `number`<br> | ||
Default: `2000` | ||
@@ -71,3 +75,3 @@ | ||
Type: `boolean` | ||
Type: `boolean`<br> | ||
Default: `false` | ||
@@ -79,3 +83,3 @@ | ||
Type: `boolean` | ||
Type: `boolean`<br> | ||
Default: `false` | ||
@@ -93,3 +97,3 @@ | ||
Type: `array` | ||
Type: `Array` | ||
@@ -106,24 +110,21 @@ Require custom modules before tests are run. | ||
```js | ||
gulp.task('default', function () { | ||
return gulp.src('test.js') | ||
gulp.task('default', () => | ||
gulp.src('test.js') | ||
.pipe(mocha()) | ||
.once('error', function () { | ||
.once('error', () => { | ||
process.exit(1); | ||
}) | ||
.once('end', function () { | ||
.once('end', () => { | ||
process.exit(); | ||
}); | ||
}); | ||
}) | ||
); | ||
``` | ||
### CoffeeScript | ||
### Babel | ||
Add `require('coffee-script/register')` to the top of your `gulpfile.js`. | ||
Add `require('babel-core/register');` to the top of your `gulpfile.js`. Make sure to read the [Babel docs](https://babeljs.io/docs/usage/require/). | ||
### Babel | ||
Add `require('babel/register')` to the top of your `gulpfile.js`. | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
6438
124
1
1
+ Addedreq-cwd@^1.0.1
+ Addedbrowser-stdout@1.3.0(transitive)
+ Addedcommander@2.9.0(transitive)
+ Addeddebug@2.6.8(transitive)
+ Addeddiff@3.2.0(transitive)
+ Addedglob@7.1.1(transitive)
+ Addedgraceful-readlink@1.0.1(transitive)
+ Addedhas-flag@1.0.0(transitive)
+ Addedhe@1.1.1(transitive)
+ Addedjson3@3.3.2(transitive)
+ Addedlodash._baseassign@3.2.0(transitive)
+ Addedlodash._basecreate@3.0.3(transitive)
+ Addedlodash.create@3.1.1(transitive)
+ Addedmocha@3.5.3(transitive)
+ Addedms@2.0.0(transitive)
+ Addedreq-cwd@1.0.1(transitive)
+ Addedreq-from@1.0.1(transitive)
+ Addedresolve-from@2.0.0(transitive)
+ Addedsupports-color@3.1.2(transitive)
- Removedresolve-from@^1.0.0
- Removedcommander@0.6.12.3.0(transitive)
- Removeddebug@2.2.0(transitive)
- Removeddiff@1.4.0(transitive)
- Removedescape-string-regexp@1.0.2(transitive)
- Removedglob@3.2.11(transitive)
- Removedjade@0.26.3(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removedminimatch@0.3.0(transitive)
- Removedmkdirp@0.3.0(transitive)
- Removedmocha@2.5.3(transitive)
- Removedms@0.7.1(transitive)
- Removedresolve-from@1.0.1(transitive)
- Removedsigmund@1.0.1(transitive)
- Removedsupports-color@1.2.0(transitive)
- Removedto-iso-string@0.0.2(transitive)
Updatedmocha@^3.0.0