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

Loading Config asynchronously #578

Closed
axemclion opened this Issue Mar 5, 2014 · 8 comments

Comments

Projects
None yet
3 participants
@axemclion
Contributor

axemclion commented Mar 5, 2014

Currently the configuration needs to be specified as an object in module.exports. This means that everything, include the browser capabilities need to be synchronous.

However, packages like firefox-profile are easier to use with their async API. Generating the zip and crx file for chrome extensions also work well with an async API.

What would be the best way to use the config where the capabilities object is generated asynchronously? Is this the best way of using protractor?

P.S: I am working on browser-perf and am looking at reusing protractor tests to test performance of Angular web apps. I am also generating the browser capabilities object asynchronously, hence this question.

@juliemr

This comment has been minimized.

Show comment
Hide comment
@juliemr

juliemr Mar 5, 2014

Member

I'd be curious to learn if others have this same use case. If it's a common problem, then Protractor should introduce native support. Otherwise, using it as a library (as you linked) is probably the best way.

Member

juliemr commented Mar 5, 2014

I'd be curious to learn if others have this same use case. If it's a common problem, then Protractor should introduce native support. Otherwise, using it as a library (as you linked) is probably the best way.

@axemclion

This comment has been minimized.

Show comment
Hide comment
@axemclion

axemclion Mar 5, 2014

Contributor

Is there a full example of using it as the library? I would not want to replicate the runner.js code or the cli.js code.

Also, using it as a library would mean that I cannot double up measuring perf tests when running from CLI easily.

Does it make sense to support both sync as async? When the config object has promise methods, the async behavior is implied, else the normal case works.

Contributor

axemclion commented Mar 5, 2014

Is there a full example of using it as the library? I would not want to replicate the runner.js code or the cli.js code.

Also, using it as a library would mean that I cannot double up measuring perf tests when running from CLI easily.

Does it make sense to support both sync as async? When the config object has promise methods, the async behavior is implied, else the normal case works.

@axemclion

This comment has been minimized.

Show comment
Hide comment
@axemclion

axemclion Mar 15, 2014

Contributor

The problem with using protractor as a library is that protractor does not expose runners or config parsers. When using it as a library, would I have to re-write all the code to manually parse the library?

Given that q is already used in protractor, can the getConfig method return a promise? This way, both sync and async will be supported automatically.

Contributor

axemclion commented Mar 15, 2014

The problem with using protractor as a library is that protractor does not expose runners or config parsers. When using it as a library, would I have to re-write all the code to manually parse the library?

Given that q is already used in protractor, can the getConfig method return a promise? This way, both sync and async will be supported automatically.

@axemclion

This comment has been minimized.

Show comment
Hide comment
@axemclion

axemclion Mar 17, 2014

Contributor

@juliemr Here is an example of how I am able to record performance metrics using existing protractor test cases - https://gist.github.com/axemclion/9594795

The only problem is that I am having to generate a temporary configuration and then run protractor. This way, I am able to add the additional browser configuration to the capabilities object.

I tried using it as a library, but realized that I was pretty much re-writing all the code from ConfigParser.js and Runner.js. Given that they are not exposed by protractor module, is there a way to reuse the config parser? Any other advice on how to structure this better so that it can work better with Protractor configurations and can be invoked directly from the command like, like protractor test?

Contributor

axemclion commented Mar 17, 2014

@juliemr Here is an example of how I am able to record performance metrics using existing protractor test cases - https://gist.github.com/axemclion/9594795

The only problem is that I am having to generate a temporary configuration and then run protractor. This way, I am able to add the additional browser configuration to the capabilities object.

I tried using it as a library, but realized that I was pretty much re-writing all the code from ConfigParser.js and Runner.js. Given that they are not exposed by protractor module, is there a way to reuse the config parser? Any other advice on how to structure this better so that it can work better with Protractor configurations and can be invoked directly from the command like, like protractor test?

@juliemr

This comment has been minimized.

Show comment
Hide comment
@juliemr

juliemr Mar 20, 2014

Member

Hey, sorry for the slow responses here. You can always use the ConfigParser (even if it's not exposed) by doing require('protractor/lib/configParser')

The idea of using Protractor as a library was generally that you would want your own runner - that's why it's not exposed explicitly.

I like your solution of generating a temporary config for now.

Member

juliemr commented Mar 20, 2014

Hey, sorry for the slow responses here. You can always use the ConfigParser (even if it's not exposed) by doing require('protractor/lib/configParser')

The idea of using Protractor as a library was generally that you would want your own runner - that's why it's not exposed explicitly.

I like your solution of generating a temporary config for now.

@juliemr

This comment has been minimized.

Show comment
Hide comment
@juliemr

juliemr May 23, 2014

Member

As mentioned in the pull request, I think adding complexity to the config isn't the way to go - prefer using the runner and launching yourself.

Member

juliemr commented May 23, 2014

As mentioned in the pull request, I think adding complexity to the config isn't the way to go - prefer using the runner and launching yourself.

@juliemr juliemr closed this May 23, 2014

@axemclion

This comment has been minimized.

Show comment
Hide comment
@axemclion

axemclion Nov 17, 2014

Contributor

For the sake of completeness adding information about the performance test suite here - The project https://github.com/axemclion/protractor-perf can be run just like protractor command line, with the same options. It also checks for perf regressions in addition to functional regressions.

Contributor

axemclion commented Nov 17, 2014

For the sake of completeness adding information about the performance test suite here - The project https://github.com/axemclion/protractor-perf can be run just like protractor command line, with the same options. It also checks for perf regressions in addition to functional regressions.

@donaldpipowitch

This comment has been minimized.

Show comment
Hide comment
@donaldpipowitch

donaldpipowitch Aug 31, 2015

What is the best way to do it now? I'd love to have some async code in my configuration (or have #2334).

donaldpipowitch commented Aug 31, 2015

What is the best way to do it now? I'd love to have some async code in my configuration (or have #2334).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment