diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fac54537..d4fe9eae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ locate('//table') * Added `event.test.finished` which fires synchronously for both failed and passed tests. * [WebDriverIO][Protractor][Nightmare][Puppeteer] Full page screenshots on failure disabled by default. See [issue #1600](https://github.com/Codeception/CodeceptJS/issues/1060). You can enabled them with `fullPageScreenshots: true`, however they may work unstable in Selenium. * `within` blocks can return values. See [updated documentation](https://codecept.io/basics/#within). +* Removed doublt call to `_init` in helpers. Fixes issue [#1036](https://github.com/Codeception/CodeceptJS/issues/1036) * Added scenario and feature configuration via fluent API: ```js diff --git a/lib/listener/helpers.js b/lib/listener/helpers.js index dd2bf971e..1a3e7806a 100644 --- a/lib/listener/helpers.js +++ b/lib/listener/helpers.js @@ -22,10 +22,6 @@ module.exports = function () { }); }; - event.dispatcher.on(event.all.before, () => { - runHelpersHook('_init'); - }); - event.dispatcher.on(event.suite.before, (suite) => { runAsyncHelpersHook('_beforeSuite', suite, true); }); diff --git a/test/data/helper.js b/test/data/helper.js index 5cc650b5b..c426266ee 100644 --- a/test/data/helper.js +++ b/test/data/helper.js @@ -5,6 +5,10 @@ class MyHelper extends Helper { return 'hello world'; } + _init() { + console.log('Helper: I\'m initialized'); + } + _beforeSuite() { console.log('Helper: I\'m simple BeforeSuite hook'); } diff --git a/test/runner/codecept_test.js b/test/runner/codecept_test.js index b0478307f..a34f66d04 100644 --- a/test/runner/codecept_test.js +++ b/test/runner/codecept_test.js @@ -98,7 +98,12 @@ describe('CodeceptJS Runner', () => { exec(codecept_run_config('codecept.testhooks.json'), (err, stdout) => { const lines = stdout.match(/\S.+/g); + const uniqueLines = lines.filter((v, i, a) => a.indexOf(v) === i); + + expect(uniqueLines.length).to.eql(lines.length, `No duplicates in output +${lines} \n\n -${uniqueLines}`); + expect(lines).to.include.members([ + 'Helper: I\'m initialized', 'Helper: I\'m simple BeforeSuite hook', 'Test: I\'m simple BeforeSuite hook', 'Test: I\'m generator BeforeSuite hook', @@ -116,6 +121,7 @@ describe('CodeceptJS Runner', () => { 'Test: I\'m async/await AfterSuite hook', 'Helper: I\'m simple AfterSuite hook', ]); + stdout.should.include('OK | 1 passed'); assert(!err); done();