diff --git a/examples/github_test.js b/examples/github_test.js index 209437cde..060ca3bfb 100644 --- a/examples/github_test.js +++ b/examples/github_test.js @@ -14,6 +14,7 @@ Scenario('search', (I) => { Scenario('signin', (I) => { I.click('Sign in'); + I.say('it should not enter'); I.see('Sign in to GitHub'); I.fillField('Username or email address', 'something@totest.com'); I.fillField('Password', '123456'); diff --git a/lib/actor.js b/lib/actor.js index e963f852e..03eb8ce72 100644 --- a/lib/actor.js +++ b/lib/actor.js @@ -4,6 +4,7 @@ let container = require('./container'); let methodsOfObject = require('./utils').methodsOfObject; let recorder = require('./recorder'); let event = require('./event'); +let output = require('./output'); /** * Fetches all methods from all enabled helpers, @@ -14,10 +15,10 @@ module.exports = function (obj) { obj = obj || {}; let helpers = container.helpers(); + + // add methods from enabled helpers Object.keys(helpers) - .map(function (key) { - return helpers[key]; - }) + .map((key) => helpers[key]) .forEach((helper) => { methodsOfObject(helper, 'Helper') .filter((method) => { @@ -32,11 +33,15 @@ module.exports = function (obj) { step.name = actionAlias; step.actor = container.translation().I; } + // add methods to promise chain return recordStep(step, Array.prototype.slice.call(arguments)); }; }); }); + // add print comment method + obj.say = (msg) => recorder.add(`say ${msg}`, () => output.say(msg)); + return obj; }; diff --git a/test/unit/actor_test.js b/test/unit/actor_test.js index d21bdf842..0b2338473 100644 --- a/test/unit/actor_test.js +++ b/test/unit/actor_test.js @@ -23,8 +23,8 @@ describe('Actor', () => { I = actor(); }); - it('should take all methods of helpers', () => { - I.should.have.keys(['hello', 'bye', 'greeting']); + it('should take all methods from helpers and built in', () => { + I.should.have.keys(['hello', 'bye', 'greeting', 'say']); }); it('should return promise', () => {