Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

chore(docs): new framework requirements in Protractor 6.0 #3893

Merged
merged 1 commit into from
Dec 30, 2016

Conversation

sjelin
Copy link
Contributor

@sjelin sjelin commented Dec 29, 2016

This will allow us to implement restartBrowserBetweenTests without the control flow, and in the future maybe add more features users have been asking for.

@sjelin sjelin requested a review from juliemr December 29, 2016 20:50
@sjelin sjelin added this to the 5.0 milestone Dec 29, 2016
@juliemr
Copy link
Member

juliemr commented Dec 29, 2016

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`,
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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
Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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*
Copy link
Member

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:
Copy link
Member

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.

@sjelin sjelin force-pushed the newfw branch 2 times, most recently from aaba4fa to e0e278b Compare December 29, 2016 23:22
@sjelin
Copy link
Contributor Author

sjelin commented Dec 29, 2016

@juliemr All comments addressed, but you're going to need to take a look again 😛

sjelin added a commit to sjelin/protractor that referenced this pull request Dec 29, 2016
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<{
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Member

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)

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

sjelin added a commit to sjelin/protractor that referenced this pull request Dec 30, 2016
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
sjelin added a commit to sjelin/protractor that referenced this pull request Dec 30, 2016
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
@sjelin
Copy link
Contributor Author

sjelin commented Dec 30, 2016

@juliemr all comments addressed.

@juliemr
Copy link
Member

juliemr commented Dec 30, 2016 via email

@sjelin sjelin merged commit c194af8 into angular:beta Dec 30, 2016
sjelin added a commit to sjelin/protractor that referenced this pull request Dec 30, 2016
sjelin added a commit to sjelin/protractor that referenced this pull request Dec 30, 2016
sjelin added a commit to sjelin/protractor that referenced this pull request Jan 3, 2017
sjelin added a commit to sjelin/protractor that referenced this pull request Jan 18, 2017
sjelin added a commit that referenced this pull request Jan 18, 2017
sjelin added a commit that referenced this pull request Jan 18, 2017
igniteram pushed a commit to igniteram/protractor that referenced this pull request Feb 21, 2017
bodyduardU pushed a commit to bodyduardU/protractor that referenced this pull request Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants