-
Notifications
You must be signed in to change notification settings - Fork 2.3k
chore(docs): new framework requirements in Protractor 6.0 #3893
Conversation
See issue at #3894 |
- The returned promise must follow the same rules as before. | ||
|
||
Note that `testPass` and `testFail` events will be replaced by | ||
`runner.afterEach`, `runner.runTestPreparer` will be replaced by `beforeAll`, |
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.
Why change the API for runTestPreparer
? This seems like unnecessary churn.
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.
Just to make it more consistent
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 don't think that's worth the braking change, if we aren't updating the emitters.
|
||
- The returned promise must follow the same rules as before. | ||
|
||
Note that `testPass` and `testFail` events will be replaced by |
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 I'd prefer to make minimal changes here. I think we can keep the testPass
and testFail
events, since there are good and useful patterns for wanting to do event-based handling of those things without blocking the asynchronous flow. I think we should just add the afterEach
(or beforeEach
, not sure it really matters where we put the edge case).
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 would still have the runner emit testPass
and testFail
, we would just do that in runner.afterEach
. So instead of having the framework handle event emission we'd do it ourselves. And I think it's pretty redundant to have the frameworks do both.
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.
Another potential problem: I think frameworks should treat afterEach
as part of the test, so if that errors, it could potentially change the test outcome from pass to fail. And the framework might not even have access to pass/fail stats before it's fully done.
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.
Ok, I think you're right
|
||
Frameworks following the old specification will still work until at least | ||
Protractor 7.0. If you write a backwards-compatible framework, Protractor will | ||
automatically detect that and handle deduplication. However, do not *partially* |
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 go with my comments above and only add the afterEach
function, then we don't need this warning.
In Protractor 6.0, the requirements will be changed to the following: | ||
|
||
- `runner.afterEach` will have to be called after each test finishes. It must | ||
be called with a `testInfo` object of the following structure: |
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.
Should mention that this needs to wait on a returned promise.
aaba4fa
to
e0e278b
Compare
@juliemr All comments addressed, but you're going to need to take a look again 😛 |
Also converted the code in `lib/frameworks/README.md` to typescript. Also exported the type of `Runner` so that framework-writers can use typescript. Closes angular#3893
optionally a `specResults` object of the following structure: | ||
|
||
```ts | ||
specResults: Array<{ |
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 don't think the switch to Array
makes this more readable.
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 was trying to make it an actual typescript type. But I'll change it back, since this isn't real code anyway.
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.
Done
If your framework does not export a `protractorVersion` property which is at | ||
least 6.0.0, and `testPass` or `testFail` are emitted before | ||
`runner.afterEach` is called, Protractor will assume your framework is old and | ||
does not support `runner.afterEach`. In this case, Protractor will call |
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.
Why don't we just check for presence of afterEach
on the object? This seems simpler than requiring a version export.
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.
The framework calls us, not the other way around. There's no way to check that they plan on calling us
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 could also add a requirement that they call afterEach
before they emit testPass
or testFail
. Jasmine and Mocha will certainly do this. But I'm concerned that this might be difficult for other frameworks.
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.
Ah of course, my bad. Asking for a version still feels like a very blunt solution though - we could instead warn if afterEach
isn't being called at all (might not get real-time errors, but we could certainly warn if, say, afterEach
wasn't called during an entire run)
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.
So let's say we see a testPass
event but haven't seen afterEach
yet and restartBrowserBetweenTests
is on. Do we assume it's an old framework and call browser.restart
now? Do we wait in hopes that afterEach
will be called in the future?
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'd say we log a warning if we see that behavior and move on without trying to fix it. Too harsh?
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 guess it's fine. So we'd just break restartBrowserBetweenTests
on old frameworks then?
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.
Right. And obviously we'll update frameworks that we control before we make the breaking change.
Also converted the code in `lib/frameworks/README.md` to typescript. Also exported the type of `Runner` so that framework-writers can use typescript. Part of angular#3893
Also converted the code in `lib/frameworks/README.md` to typescript. Also exported the type of `Runner` so that framework-writers can use typescript. Part of angular#3893
Also converted the code in `lib/frameworks/README.md` to typescript. Also exported the type of `Runner` so that framework-writers can use typescript. Part of angular#3893
@juliemr all comments addressed. |
LGTM!
…On Thu, Dec 29, 2016 at 7:43 PM, Sammy Jelin ***@***.***> wrote:
@juliemr <https://github.com/juliemr> all comments addressed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3893 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB_DrRirZlP9_bQwdspUDGuENYYx6-Icks5rNH3kgaJpZM4LX1kT>
.
|
Follow up to angular#3893. Part of angular#3893
Follow up to angular#3893. Part of angular#3893
Follow up to angular#3893. Part of angular#3893
Follow up to angular#3893. Part of angular#3893
Follow up to angular#3893. Part of angular#3893
Follow up to angular/protractor#3893. Part of #3893
This will allow us to implement
restartBrowserBetweenTests
without the control flow, and in the future maybe add more features users have been asking for.