Skip to content

Commit

Permalink
Add helpers for easy testgen integration
Browse files Browse the repository at this point in the history
  • Loading branch information
schipiga committed Feb 16, 2018
1 parent c96702c commit f215464
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/config.js
Expand Up @@ -81,7 +81,7 @@ var config = _.merge(config, {
});

/* Use CLI arguments */
config.timeouts.chunk = (args.chunkTimeout || 180) * 1000;
config.timeouts.chunk = (args.chunkTimeout || 180) * 1000 || null;
config.clearReport = !args.dontClearReport;
config.uncaught = (args.uncaught || "log").toLowerCase();
expect([ "log", "fail", "mocha" ],
Expand Down
12 changes: 1 addition & 11 deletions lib/error.js
Expand Up @@ -6,17 +6,7 @@
*/
var util = require("util");

var BaseError = require("es6-error");
/**
* Error which is thrown in `GlaceJS`, if no more specific error is defined.
*
* @class
* @arg {string} message - Error message.
*/
var GlaceError = module.exports.GlaceError = function (message) {
BaseError.call(this, message);
};
util.inherits(GlaceError, BaseError);
var GlaceError = require("glace-utils").GlaceError;
/**
* Error which is thrown when configuration is wrong.
*
Expand Down
11 changes: 10 additions & 1 deletion lib/globals.js
Expand Up @@ -107,9 +107,18 @@ global.CONF = CONF;
* Atomic steps collection.
*
* @global
* @type {Steps}
* @see {@link module:steps/index|steps} to get more details about its methods.
*/
global.SS = new (require("./steps"));
global.SS = new Proxy(
new (require("./steps")),
{
get: (target, prop) => {
if (prop in target) return target[prop];
throw new U.GlaceError(
`Steps instance doesn't have property '${prop}'`);
},
});
/**
* Execute tests scope.
*
Expand Down
25 changes: 24 additions & 1 deletion lib/steps/index.js
Expand Up @@ -7,15 +7,38 @@
* its instance [SS](global.html#SS). It mixes steps from plugins too.
* @name Steps
* @mixes TimerSteps
* @prop {object} ctx - Storage to share some data between steps.
*/

var _ = require("lodash");
var U = require("glace-utils");

var CONF = require("../config");
var plugins = require("../plugins");

var Steps = function () {};
var Steps = function () {
this.ctx = {};
};
module.exports = Steps;
/**
* Helper to reset steps context.
*
* @method
*/
Steps.prototype.resetCtx = function () {
this.ctx = {};
};
/**
* Helper to check whether test was failed before current step.
*
* @method
* @return {undefined|boolean} `undefined` if test is absent,
* `true` if test was failed, `false` otherwise.
*/
Steps.prototype.isTestFailed = function () {
if (!CONF.curTestCase) return;
return !!CONF.curTestCase.errors.length;
};
/**
* Step to enter to interactive debugging mode. May be used inside test if you
* need to debug test in runtime.
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -23,9 +23,8 @@
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"colors": "^1.1.2",
"es6-error": "^4.1.1",
"fs-extra": "^4.0.3",
"glace-utils": "^1.1.2",
"glace-utils": "^1.1.3",
"lodash": "^4.17.5",
"mocha": "^4.0.1",
"rewire": "^3.0.2",
Expand Down

0 comments on commit f215464

Please sign in to comment.