Socket
Socket
Sign inDemoInstall

it

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it - npm Package Compare versions

Comparing version 0.2.7 to 1.0.0

.idea/libraries/it_node_modules.xml

4

lib/browser/formatters/html.js

@@ -121,2 +121,6 @@ "use strict";

actionSkipped: function (action) {
this.__addAction(action);
},
actionPending: function (action) {

@@ -123,0 +127,0 @@ this.__addAction(action);

9

lib/formatters/dot.js

@@ -20,13 +20,14 @@ "use strict";

actionSuccess: function printSuccess() {
this._super(arguments);
stdout.write(style(".", ['green']));
},
actionPending: function printPending() {
this._super(arguments);
actionSkipped: function printSkipped() {
stdout.write(style(".", ['cyan']));
},
actionPending: function printPending() {
stdout.write(style(".", ['red']));
},
actionError: function printError() {
this._super(arguments);
stdout.write(style(characters.ITALIC_X, ['red']));

@@ -33,0 +34,0 @@ }

@@ -6,17 +6,13 @@ "use strict";

var pluralize = function (count, str) {
return count !== 1 ? str + "s" : str;
};
_.declare({
instance: {
numActions: 0,
constructor: function () {
this.errors = [];
_.bindAll(this, ["startTests", "testError", "printFinalSummary", "listenTest", "listenAction", "testRun",
"testEnd", "actionError", "actionSuccess", "actionPending", "testsDone"]);
_.bindAll(this, ["startTests", "testError", "_testError", "printFinalSummary", "listenTest", "listenAction", "testRun",
"testEnd", "testsDone", "actionError", "_actionError", "actionSuccess", "actionPending", "actionSkipped"]);
_.bus.on("start", this.startTests);
_.bus.on("error", this.testError);
_.bus.on("error", this._testError);
_.bus.on("done", this.testsDone);

@@ -30,3 +26,3 @@ _.bus.on("test", this.listenTest);

test.on("run", this.testRun);
test.on("error", this.testError);
test.on("error", this._testError);
test.on("done", this.testEnd);

@@ -36,6 +32,7 @@ },

listenAction: function listenAction(action) {
action.on("error", this.actionError);
this.numActions++;
action.on("error", this._actionError);
action.on("success", this.actionSuccess);
action.on("pending", this.actionPending);
action.on("skipped", this.actionSkipped);
},

@@ -51,20 +48,28 @@

testRun: function printTitle() {
},
actionSuccess: function printSuccess() {
},
actionPending: function printPending() {
},
actionSkipped: function printSkipped() {
},
actionError: function printError(action) {
actionError: function actionError() {
},
testError: function printError(test) {
},
_actionError: function printError(action) {
var error = action.get("summary").error;
this.errors.push({error: error, test: action});
return this.actionError.apply(this, arguments);
},
testError: function printError(test) {
_testError: function _testError(test) {
this.errors.push({error: test.error, test: test});
return this.testError.apply(this, arguments);
},

@@ -76,3 +81,3 @@

}
var errCount = 0, successCount = 0, pendingCount = 0, errors = {}, duration = 0;
var errCount = 0, successCount = 0, skippedCount = 0, pendingCount = 0, errors = {}, duration = 0;
_(summary).forEach(function (sum) {

@@ -89,2 +94,4 @@ duration += sum.duration;

pendingCount++;
} else if (sum.status === "skipped") {
skippedCount++;
} else {

@@ -96,3 +103,11 @@ errors[i] = sum.error;

})(summary);
return {errCount: errCount, successCount: successCount, pendingCount: pendingCount, errors: errors, duration: duration};
return {
totalCount: this.numActions,
errCount: errCount,
successCount: successCount,
skippedCount: skippedCount,
pendingCount: pendingCount,
errors: errors,
duration: duration
};
},

@@ -112,16 +127,26 @@

var stats = this.processSummary(test.summary || test.get("summary"));
var errCount = stats.errCount, successCount = stats.successCount, pendingCount = stats.pendingCount, duration = stats.duration;
var totalCount = stats.totalCount,
errCount = stats.errCount,
successCount = stats.successCount,
pendingCount = stats.pendingCount,
skippedCount = stats.skippedCount,
duration = stats.duration;
console.log(format("Finished in %s", this.formatMs(duration)));
var out = [
successCount + pluralize(successCount, " example"),
errCount + pluralize(errCount, " error"),
totalCount + " total",
successCount + " passed",
errCount + " failed",
skippedCount + " skipped",
pendingCount + " pending"
];
var color = pendingCount > 0 ? 'cyan' : errCount > 0 ? 'red' : 'green';
var color = 'green';
if (errCount > 0 || pendingCount > 0) {
color = 'red';
} else if (skippedCount > 0) {
color = 'cyan';
}
console.log(style(out.join(", "), color));
this._static.list(this.errors);
return errCount ? 1 : 0;
return errCount || pendingCount ? 1 : 0;
}
},

@@ -151,3 +176,3 @@

list: function (errors) {
console.error();
console.log();
errors.forEach(function (test, i) {

@@ -169,3 +194,3 @@ // format

console.error(fmt, (i + 1), j, test.test.get("fullName"), msg, stack);
console.log(fmt, (i + 1), j, test.test.get("fullName"), msg, stack);
}

@@ -172,0 +197,0 @@ });

@@ -21,3 +21,2 @@ "use strict";

actionSuccess: function (action) {
this._super(arguments);
var level = action.level, summary = action.get("summary");

@@ -28,4 +27,8 @@ console.log(style(multiply("\t", level) + characters.CHECK + " %s (%dms)", ['green']), action.description, summary.duration);

actionPending: function (action) {
this._super(arguments);
var summary = action.get("summary"), level = action.level;
console.log(style(multiply("\t", level) + characters.ITALIC_X + " %s (%dms)", ['yellow']), action.description, summary.duration);
},
actionSkipped: function (action) {
var summary = action.get("summary"), level = action.level;
console.log(style(multiply("\t", level) + characters.LAMBDA + " %s (%dms)", ['cyan']), action.description, summary.duration);

@@ -35,3 +38,2 @@ },

actionError: function printError(action) {
this._super(arguments);
var level = action.level, summary = action.get("summary");

@@ -38,0 +40,0 @@ console.log(style(multiply("\t", level) + characters.ITALIC_X + " %s, (%dms)", ['red', "bold"]), action.description, summary.duration);

@@ -13,23 +13,13 @@ "use strict";

instance: {
numActions: 0,
ran: 0,
passed: 0,
failed: 0,
listenAction: function () {
this.numActions++;
return this._super(arguments);
},
startTests: function (tests) {
console.log(format('%d..%d', 1, (this.numActions = tests.numActions)));
console.log(format('%d..%d', 1, (tests.numActions)));
},
actionSuccess: function printSuccess(action) {
this.passed++;
console.log(format('ok %d %s', ++this.ran, getActionName(action)));
},
actionPending: function printPending(action) {
actionSkipped: function printSkipped(action) {
console.log(format('ok %d %s # SKIP -', ++this.ran, getActionName(action)));

@@ -39,3 +29,2 @@ },

actionError: function printError(action) {
this.failed++;
var summary = action.get("summary"), err = summary.error;

@@ -56,7 +45,11 @@ console.log(format('not ok %d %s', ++this.ran, getActionName(action)));

printFinalSummary: function () {
console.log('# tests ' + (this.passed + this.failed));
console.log('# pass ' + this.passed);
console.log('# fail ' + this.failed);
return this.failed ? 1 : 0;
printFinalSummary: function (test) {
var summary = this.processSummary(test.summary);
console.log('# total ' + this.numActions);
console.log('# passed ' + summary.successCount);
console.log('# failed ' + summary.errCount);
console.log('# skipped ' + summary.skippedCount);
console.log('# pending ' + summary.pendingCount);
this._static.list(this.errors);
return summary.errCount || summary.pendingCount ? 1 : 0;
}

@@ -63,0 +56,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

constructor: function (description, parent, level, action) {
constructor: function (description, parent, level, action, status) {
this._super(arguments);

@@ -29,3 +29,3 @@ this.level = level;

duration: 0, // test is pending
status: 'pending',
status: status || 'pending',
error: false

@@ -50,12 +50,32 @@ };

run: function () {
var ret = new Promise();
skipped: function (start) {
merge(this.get("summary"), { start: start, end: start, duration: 0, status: "skipped"});
this.emit("skipped", this);
return this.get("summary");
},
run: function (be, ae) {
if (this.__summary.status === "skipped") {
this.emit("skipped", this);
return new Promise().callback();
}
var start = new Date();
if (this.stub) {
// this test is pending (read: not defined yet)
ret = this.action;
this.emit("pending", this);
} else {
ret = this.action(this.parent).then(
return _.serial(be)
.then(_.bind(this, function () {
start = new Date();
var ret;
if (this.stub) {
// this test is pending (read: not defined yet)
ret = this.action;
this.emit(this.__summary.status, this);
} else {
ret = this.action(this.parent);
}
return ret;
})).then(
_.bind(this, function () {
return _.serial(ae);
})
).then(
_.bind(this, function () {
return this.success(start, new Date());

@@ -67,4 +87,2 @@ }),

);
}
return ret;
},

@@ -71,0 +89,0 @@

@@ -42,3 +42,3 @@ "use strict";

}
_.bindAll(this, ["_addAction", "ignoreErrors", "_addTest", "timeout", "getAction", "beforeAll", "beforeEach", "afterAll", "afterEach", "context", "get", "set", "skip"]);
_.bindAll(this, ["_addAction", "ignoreErrors", "_failSiblings", "_addTest", "timeout", "getAction", "beforeAll", "beforeEach", "afterAll", "afterEach", "context", "get", "set", "skip"]);
},

@@ -94,3 +94,2 @@

context: function (cb) {

@@ -107,6 +106,5 @@ var cloned = this._static.clone(this, null, {sub: true});

skip: function (description) {
this._addAction(description);
this._addAction(description, undefined, 'skipped');
},
_addTest: function (description, cb) {

@@ -129,4 +127,4 @@ var cloned = this._static.clone(this, description, {sub: true, level: this.level + 1, parent: this}, cb);

_addAction: function (description, cb) {
var action = new this.Action(description, this, this.level + 1, cb);
_addAction: function (description, cb, status) {
var action = new this.Action(description, this, this.level + 1, cb, status);
this.__shoulds.push(action);

@@ -139,26 +137,39 @@ return this;

var stopOnError = this.stopOnError;
return _.serial(this.__be)
.then(_.bind(this, function () {
var ret = new Promise();
action.run(this).then(
_.bind(this, function actionSuccess() {
var summary = action.get("summary");
if (summary.status === "pending") {
ret.callback();
} else if (summary.status === "passed") {
ret.callback();
} else {
ret[stopOnError ? "errback" : "callback"]();
}
}),
_.bind(this, function actionError(err) {
this.error = err;
this.emit("error", this);
}));
return action.run(this.__be, this.__ae).then(
_.bind(this, function actionSuccess() {
var ret = new Promise(),
summary = action.get("summary");
if (summary.status === "skipped" || summary.status === "passed") {
ret.callback();
} else {
ret[stopOnError ? "errback" : "callback"]();
}
return ret;
})).then(_.bind(this, function () {
return _.serial(this.__ae);
}));
}),
_.bind(this, function actionError(err) {
this.error = err;
this.emit("error", this);
})
);
},
_failSiblings: function (err) {
return _.serial(_.map(this.__shoulds, function (action) {
return _.bind(this, function () {
var ret;
if (action instanceof Action) {
this.emit("action", action);
var start = new Date();
action.failed(start, start, err);
ret = new Promise().callback();
} else {
this.emit("test", action);
action.emit("run", action);
ret = action._failSiblings(err);
}
return ret;
});
}, this));
},
run: function (filter) {

@@ -187,2 +198,5 @@ var ret;

}, this));
}),
_.bind(this, function (err) {
return this._failSiblings(err);
})

@@ -290,2 +304,8 @@ ).then(

}).sum().value();
},
skippedCount: function () {
return _(this.__shoulds).map(function (instance) {
return (instance instanceof Action) ? (instance.get("status") === "skipped" ? 1 : 0) : instance.get("skippedCount");
}).sum().value();
}

@@ -358,5 +378,5 @@

var tests = this.tests;
var summary = {summary: {}, errorCount: 0, successCount: 0, pendingCount: 0};
var summary = {summary: {}, errorCount: 0, successCount: 0, pendingCount: 0, skippedCount: 0};
if (!isEmpty(tests)) {
var keys = _.hash.keys(tests), length = 0, errorCount = 0, successCount = 0, pendingCount = 0;
var keys = _.hash.keys(tests), length = 0;
_(tests).forEach(function (test, k) {

@@ -366,2 +386,3 @@ var testSummary = test.get("summary");

summary.successCount += test.get("successCount");
summary.skippedCount += test.get("skippedCount");
summary.pendingCount += test.get("pendingCount");

@@ -368,0 +389,0 @@ if (testSummary) {

@@ -20,3 +20,3 @@ /**

reporter: function reporter(r) {
formatters.reporter(r);
return formatters.reporter(r);
},

@@ -23,0 +23,0 @@

{
"name": "it",
"description": "A testing framework for node",
"version": "0.2.7",
"version": "1.0.0",
"keywords": [

@@ -50,3 +50,5 @@ "testing",

"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-jshint": "~0.3.0"
"grunt-contrib-jshint": "~0.3.0",
"colors": "1.1.2",
"diff": "2.2.1"
},

@@ -66,4 +68,4 @@ "homepage": "http://doug-martin.github.com/it",

"engines": {
"node": ">= 0.6.1"
"node": ">= 0.10.1"
}
}
"use strict";
var it = require("../index"), assert = require("assert");
var it = require("../index"),
assert = require("assert"),
testUtil = require("./test-util");
it.describe("it bdd",function (it) {

@@ -233,2 +236,43 @@

it.describe("#beforeAll error", function (it) {
var errorMessage1, errorMessage2 = null;
it.describe("error suite", function (it) {
it.beforeAll(function () {
throw new Error("BeforeAll Error");
});
it.should("not call action if beforeAll fails", function () {
throw new Error("Action called when beforeAll failed");
});
var beforeAllAction1 = it.getAction("should not call action if beforeAll fails");
beforeAllAction1.failed = function (start, end, err) {
errorMessage1 = err.message;
return beforeAllAction1.success(start, end);
};
it.describe("nested error suite", function (it) {
it.should("not call action if beforeAll fails in parent", function () {
throw new Error("Action called when beforeAll failed in parent");
});
var beforeAllAction2 = it.getAction("should not call action if beforeAll fails in parent");
beforeAllAction2.failed = function (start, end, err) {
errorMessage2 = err.message;
return beforeAllAction2.success(start, end);
};
});
});
it.should("use the error message from beforeAll for tests if it fails", function () {
assert.equal(errorMessage1, "BeforeAll Error");
});
it.should("use the error message from beforeAll in parent for tests if it fails", function () {
assert.equal(errorMessage2, "BeforeAll Error");
});
});
it.describe("#beforeEach", function (it) {

@@ -539,2 +583,35 @@

[
"#beforeAll error",
[
"error suite",
[
"should not call action if beforeAll fails",
{
"status": "passed"
}
],
[
"nested error suite",
[
"should not call action if beforeAll fails in parent",
{
"status": "passed"
}
]
]
],
[
"should use the error message from beforeAll for tests if it fails",
{
"status": "passed"
}
],
[
"should use the error message from beforeAll in parent for tests if it fails",
{
"status": "passed"
}
]
],
[
"#beforeEach",

@@ -652,3 +729,3 @@ [

{
"status": "pending"
"status": "skipped"
}

@@ -722,9 +799,7 @@ ]

}(str, summary));
assert.deepEqual(str, expected);
testUtil.jsonDeepEqual(str, expected);
assert.isNumber(summary.duration);
});
}).as(module);
}).as(module);
"use strict";
var it = require("../index"), assert = require("assert");
var it = require("../index"),
assert = require("assert"),
testUtil = require("./test-util");

@@ -209,2 +211,3 @@ it.suite("it tdd",function (it) {

});
});

@@ -233,2 +236,43 @@

it.suite("#beforeAll error", function (it) {
var errorMessage1, errorMessage2 = null;
it.suite("error suite", function (it) {
it.beforeAll(function () {
throw new Error("BeforeAll Error");
});
it.test("should not call action if beforeAll fails", function () {
throw new Error("Action called when beforeAll failed");
});
var beforeAllAction1 = it.getAction("should not call action if beforeAll fails");
beforeAllAction1.failed = function (start, end, err) {
errorMessage1 = err.message;
return beforeAllAction1.success(start, end);
};
it.suite("nested error suite", function (it) {
it.test("should not call action if beforeAll fails in parent", function () {
throw new Error("Action called when beforeAll failed in parent");
});
var beforeAllAction2 = it.getAction("should not call action if beforeAll fails in parent");
beforeAllAction2.failed = function (start, end, err) {
errorMessage2 = err.message;
return beforeAllAction2.success(start, end);
};
});
});
it.test("should use the error message from beforeAll for tests if it fails", function () {
assert.equal(errorMessage1, "BeforeAll Error");
});
it.test("should use the error message from beforeAll in parent for tests if it fails", function () {
assert.equal(errorMessage2, "BeforeAll Error");
});
});
it.suite("#beforeEach", function (it) {

@@ -482,2 +526,27 @@

[
"#beforeAll error",
[
"error suite",
[
"should not call action if beforeAll fails",
{"status":"passed"}
],
[
"nested error suite",
[
"should not call action if beforeAll fails in parent",
{"status":"passed"}
]
]
],
[
"should use the error message from beforeAll for tests if it fails",
{"status":"passed"}
],
[
"should use the error message from beforeAll in parent for tests if it fails",
{"status":"passed"}
]
],
[
"#beforeEach",

@@ -574,3 +643,3 @@ [

{
"status": "pending"
"status": "skipped"
}

@@ -644,3 +713,3 @@ ]

}(str, summary));
assert.deepEqual(str, expected);
testUtil.jsonDeepEqual(str, expected);
assert.isNumber(summary.duration);

@@ -647,0 +716,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc