Skip to content

Commit

Permalink
Custome help in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
schipiga committed Jul 28, 2018
1 parent 76b7923 commit 2a4858d
Show file tree
Hide file tree
Showing 5 changed files with 1,004 additions and 989 deletions.
2 changes: 1 addition & 1 deletion jsdoc.json
Expand Up @@ -19,7 +19,7 @@
},
"theme": "cosmo",
"outputSourceFiles": true,
"systemName": "GlaseJS",
"systemName": "GlaceJS",
"copyright": "Copyright 2017",
"linenums": true
}
Expand Down
21 changes: 18 additions & 3 deletions lib/steps/index.js
Expand Up @@ -4,7 +4,7 @@
*
* @class
* @classdesc Contains collection of steps which may be called inside tests via
* its instance [SS](global.html#SS). It mixes steps from plugins too.
* its instance [$](global.html#$). It mixes steps from plugins too.
* @name Steps
* @mixes TimerSteps
* @prop {object} ctx - Storage to share some data between steps.
Expand Down Expand Up @@ -66,14 +66,14 @@ Steps.prototype.debug = async function () {
*
* test("my test", () => {
* chunk(async () => {
* await SS.debug();
* await $.debug();
* });
* });
*/

var onFail = CONF.session.debugOnFail;
CONF.session.debugOnFail = false;
await U.debug();
await U.debug(setupDebug());
CONF.session.debugOnFail = onFail;
};

Expand Down Expand Up @@ -151,3 +151,18 @@ Steps.getInstance = function (cls) {
Steps.register(require("./timer"));
/* Load plugins steps */
Steps.register.apply(Steps, plugins.getModules("Steps"));

/**
* Set up debug mode for glace.
* @ignore
*/
const setupDebug = () => {
global.search = $.listSteps.bind($);

const helpMsg = "In interactive mode you can execute any nodejs code or glace step.\n" +
"Available commands:\n" +
"- search([query string]) - Search a glace step according to query. " +
"For ex: > search('step to start timer')\n";

return helpMsg;
};
28 changes: 14 additions & 14 deletions lib/steps/timer.js
Expand Up @@ -6,7 +6,7 @@
* Steps to measure time.
*
* These methods will be mixed with glacejs [Steps](https://glacejs.github.io/glace-core/Steps.html)
* class and available via its instance [SS](https://glacejs.github.io/glace-core/global.html#SS)
* class and available via its instance [$](https://glacejs.github.io/glace-core/global.html#$)
* in tests.
*
* @mixin TimerSteps
Expand Down Expand Up @@ -36,7 +36,7 @@ var TimerSteps = {
* @throws {AssertionError} If pause message isn't defined.
* @example
*
* await SS.pause(1, "wait for server start");
* await $.pause(1, "wait for server start");
*/

A.step(`Sleep ${timeout} sec because ${message}`);
Expand All @@ -56,9 +56,9 @@ var TimerSteps = {
* @instance
* @example
*
* SS.startTimer();
* await SS.pause(1, "sleep a bit");
* var elapsedSeconds = SS.getTimer();
* $.startTimer();
* await $.pause(1, "sleep a bit");
* var elapsedSeconds = $.getTimer();
*/

A.step("Start timer");
Expand All @@ -75,7 +75,7 @@ var TimerSteps = {
* @instance
* @example
*
* SS.stopTimer();
* $.stopTimer();
*/

A.step("Stop timer");
Expand All @@ -94,9 +94,9 @@ var TimerSteps = {
* @throws {AssertionError} If timer isn't started.
* @example
*
* SS.startTimer();
* await SS.pause(1, "sleep a bit");
* var elapsedSeconds = SS.getTimer();
* $.startTimer();
* await $.pause(1, "sleep a bit");
* var elapsedSeconds = $.getTimer();
*/

A.step("Get timer value");
Expand All @@ -117,12 +117,12 @@ var TimerSteps = {
* @throws {AssertionError} If timer verification was failed.
* @example
*
* SS.startTimer();
* SS.checkTimer("to exist");
* $.startTimer();
* $.checkTimer("to exist");
*
* SS.startTimer();
* await SS.pause(1, "sleep a bit");
* SS.checkTimer({ "to be gte": 1 });
* $.startTimer();
* await $.pause(1, "sleep a bit");
* $.checkTimer({ "to be gte": 1 });
*/

if (typeof(condition) === "string") {
Expand Down

0 comments on commit 2a4858d

Please sign in to comment.