-
-
Notifications
You must be signed in to change notification settings - Fork 742
Fix work with promise chains #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please fix |
Wow, awesome work. We are getting closer and closer to 1.0 release! |
@@ -45,6 +49,12 @@ module.exports = function (suite) { | |||
suites.shift(); | |||
} | |||
if (!opts) opts = {}; | |||
|
|||
afterAllHooks = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was already defined at line 27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Please try to use interactive shell to check that nothing was broken for it. |
@DavertMik I think, that maybe we can track this and force close/clear browser in this cases. What do you think? Should we track this, or it should be resolved from user side? |
Yes, this makes a big problem for closing browser sessions...
But this is important to solve it in one way or another. |
@DavertMik please review the changes. |
lib/helper/SeleniumWebdriver.js
Outdated
* I.closeTabsExceptForOne(); | ||
* ``` | ||
*/ | ||
closeTabsExceptForOne() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to rename:
closeOtherTabs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -22,6 +22,7 @@ class Step { | |||
} | |||
|
|||
run() { | |||
this.startTime = new Date(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this date-time counter should be moved out to https://github.com/Codeception/CodeceptJS/blob/master/lib/listener/steps.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we place it in steps.js
then we can't pass this value properly between states. Or I don't know how to do it. If you have any suggestion, it will be awesome
lib/scenario.js
Outdated
event.emit(event.test.before); | ||
}; | ||
|
||
module.exports.teardown = function () { | ||
if (!recorder.isRunning()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you repeat this 3 lines too much.
better to make a method recorder->startUnlessRunning()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -11,6 +11,14 @@ module.exports = { | |||
passed: 'test.passed', | |||
failed: 'test.failed', | |||
}, | |||
hook: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is a bit confusing. Ok, these are special events fired by a failing after
and afterSuite
.
Ok, let's try to clarify their context. Those methods should not fail, so if they do it is an error
.
So I propose to have next events: test.after.error
, and suite.after.error
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't use test.after/suite.after, because they are already defined. I suggest test.afterError, suite.afterError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test.afterError, suite.afterError
good
lib/actor.js
Outdated
val = step.run.apply(step, args); | ||
val = step.run.apply(step, args).then(() => { | ||
step.endTime = new Date(); | ||
output.log(`-> ${step.toString()} was executed in ${(step.endTime - step.startTime) / 1000} sec`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this code to event listener
lib/interfaces/bdd.js
Outdated
@@ -88,7 +95,18 @@ module.exports = function (suite) { | |||
fn = opts; | |||
opts = {}; | |||
} | |||
|
|||
if (!afterAllHooksAreLoaded) { | |||
afterAllHooks.forEach(function (hook) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some comments about what issues does it solve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comment in test.
FYI, we collect all hooks in right order in array and then push them to suite. We start collecting hooks from helpers and after from testfile. this cause hooks reordering
(expected: After
from test -> _after
hooks from helpers -> AfterSuite
from test -> _afterSuite
hook from helpers.
actual: _after
hooks from helpers -> After
from test -> _afterSuite
hook from helpers. -> AfterSuite
from test )
This change fix this chain
Our goals:
_beforeSuite
hooks from helpers ->BeforeSuite
from test ->_before
hooks from helpers ->Before
from test - > Test steps ->_failed
hooks from helpers (if test failed) ->After
from test ->_after
hooks from helpers ->AfterSuite
from test ->_afterSuite
hook from helpers.restart
option is false - close all tabs expect one in_after
(ready for webdriverIO, SeleniumWebdriver and Protractor. For Nightmare it will be hard to add (I found only this way https://github.com/rosshinkley/nightmare-window-manager)_after
,_afterSuite
hooks even After/AfterSuite from test was failedrestart
option is false. We should start browser only one time and close it only after all tests.keepCookies
flag is enabledBonus: