Comparing version 0.3.0 to 0.4.0
13
index.js
@@ -1,15 +0,14 @@ | ||
const Mocha = require("mocha") | ||
import Mocha from "mocha" | ||
module.exports = function () { | ||
export default function () { | ||
this.mocha = function (opts) { | ||
const mocha = new Mocha(opts) | ||
return new Promise(function (resolve, reject) { | ||
return new Promise((resolve, reject) => { | ||
this.unwrap((files) => { | ||
files.forEach(file => mocha.addFile(file)) | ||
files.forEach(f => mocha.addFile(f)) | ||
mocha.run((failures) => failures > 0 | ||
? reject(failures + " error(s).") | ||
: resolve()) | ||
? reject(failures + " error(s).") : resolve()) | ||
}) | ||
}.bind(this)) | ||
}) | ||
} | ||
} |
{ | ||
"name": "fly-mocha", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Mocha plugin for Fly", | ||
@@ -11,6 +11,7 @@ "license": "MIT", | ||
"setup": "npm i && npm test", | ||
"test": "npm run lint && tape test/*.js | tspec", | ||
"spec": "npm run test | tspec", | ||
"test": "npm run lint && npm run test-harmony", | ||
"build": "echo No build task specified.", | ||
"deploy": "npm run test && git push origin master && npm publish", | ||
"test-ci": "node --harmony --harmony_arrow_functions ./node_modules/tape/bin/tape test/*.js" | ||
"test-harmony": "node --harmony --harmony_arrow_functions ./node_modules/tape/bin/tape test/*.js" | ||
}, | ||
@@ -22,2 +23,3 @@ "author": "Jorge Bucaran", | ||
"devDependencies": { | ||
"fly-util": "^4.0.1", | ||
"eslint": "^0.21.2", | ||
@@ -24,0 +26,0 @@ "tap-spec": "^4.0.2", |
const test = require("tape").test | ||
const join = require("path").join | ||
const bind = require("fly-util").bind | ||
const state = { | ||
pass: { | ||
msg: "pass spec", | ||
spec: [join("test", "spec", "pass.js")] | ||
}, | ||
fail: { | ||
msg: "fail spec", | ||
spec: [join("test", "spec", "fail.js")] | ||
} | ||
} | ||
const unwrap = function (f) { f(this.spec) } | ||
test("fly-mocha", function (t) { | ||
t.ok(true, "ok") | ||
t.end() | ||
t.plan(3) | ||
const fly = {} | ||
require(bind("../")).call(fly) | ||
t.ok(fly.mocha !== undefined, "inject mocha in fly instance") | ||
fly.unwrap = unwrap.bind(state.pass) | ||
fly.mocha() | ||
.then(() => t.ok(true, state.pass.msg)) | ||
.catch(() => t.ok(false, state.pass.msg)) | ||
fly.unwrap = unwrap.bind(state.fail) | ||
fly.mocha() | ||
.then(() => t.ok(false, state.fail.msg)) | ||
.catch(() => t.ok(true, state.fail.msg)) | ||
}) |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
5502
11
51
4
2