angularjs-eclipse icon indicating copy to clipboard operation
angularjs-eclipse copied to clipboard

Run/Debug Protractor tests

Open angelozerr opened this issue 8 years ago • 16 comments

It should be cool if weio could run/debug protractor test. To do that we could provide an extension point to create a launch for protractor. We could implement this extension point with several JavaScript Debugger like we have done for debugging tern plugins.

@piotrtomiak what do you think about that?

See discussions at:

  • https://www.genuitec.com/forums/topic/support-for-protractor/
  • https://dev.eclipse.org/mhonarc/lists/wtp-dev/msg09603.html

angelozerr avatar Jan 08 '16 18:01 angelozerr

@angelozerr sounds like a great plan. Can you tell me what kind of input would you expect from me? I have read your suggestions on the Genuitec forum regarding debugger and they are good. We are considering them for improvements in the near future. However, as far as I understood you want to create a dedicated launch config for protractor tests, like for JUnit?

piotrtomiak avatar Jan 12 '16 12:01 piotrtomiak

@angelozerr sounds like a great plan.

Cool:)

Can you tell me what kind of input would you expect from me? I have read your suggestions on the Genuitec forum regarding debugger and they are good.

For the moment, nothing:) I would like just share you my plan.

We are considering them for improvements in the near future.

Cool

However, as far as I understood you want to create a dedicated launch config for protractor tests, like for JUnit?

No, I don't want to do that. I want to reuse your work on debugger. I have started to refactor your debugger work to support other thing to launch than tern and it starts working: I can select spec.js file and do run or debug and it debugs the protractor. I will commit soon and I need feedback because I'm not an user of protractor (but more people needs that).

angelozerr avatar Jan 12 '16 13:01 angelozerr

However the only restriction is that protractor folder (getted with npm install protractor) must be inside the workspace, because debugger waits an IResource.

angelozerr avatar Jan 12 '16 13:01 angelozerr

@angelozerr I will work on removing this limitation. One thing here is that usually the node modules would get installed into "node_modules" folder of the project itself. Then it would be in the workspace.

piotrtomiak avatar Jan 12 '16 17:01 piotrtomiak

@angelozerr I will work on removing this limitation.

Cool!

One thing here is that usually the node modules would get installed into "node_modules" folder of the project itself. Then it would be in the workspace.

Yes I have started like this. User need to do npm install protractor inside her project. After that we could improve it when you will remove this limitation.

My other idea is that user could create a "protractor" project which hosts protractor cli.js etc to avoid doing npm install protractor in each project.

angelozerr avatar Jan 12 '16 17:01 angelozerr

@piotrtomiak if you are interested you can play now with protractor to run/debug. See https://github.com/angelozerr/angularjs-eclipse/wiki/Protractor

To run/debug protractor, I use your tern debugger that I have a lot modified to start tern , protractor and other thing.

I have not created a specific protractor launch configuration type, because I use tern debugger which already uses a launch configuration type,. I don't know how to use a launch configuration type inside an other launch configuration type, have you an idea?

angelozerr avatar Jan 15 '16 17:01 angelozerr

@piotrtomiak if you are interested you can play now with protractor to run/debug.

Great support! I think that customizable Protractor launch configs is the only thing missing.

To run/debug protractor, I use your tern debugger that I have a lot modified to start tern , protractor and other thing.

That was a good idea, that way you have a nice framework you can use to provide support for other specialized debug/run launches. However, generated launch configs were not intended to be visible to the users, so wrapping that up into a Protractor launch is the way to go.

I don't know how to use a launch configuration type inside an other launch configuration type, have you an idea?

There are several ways to do it. One is to define a new launch configuration type (Protractor) and from withing that launch configuration type delegate you create and call the dependent launch configuration delegate (debugger) passing appropriate launch configuration options.

So, basically you would create a protractor launch configuration delegate, which under the hood in its launch method would just make a call through "tern debugger" framework to appropriate debugger launcher. The options for the launch would be customizable through the Protractor launch interface and that way you can hide some stuff from the users or expose some important stuff in a prettier way. The protractor launch would be the one which is persisted and visible to the user, the debugger launch config would be temporary and not accessible to the user (as it is with Tern debug launches). This is a simple way to avoid any plugin dependency. It has just one drawback - the icon of the launch in the Debug view will not be easily customizable, though I think it should be possible.

Let me know if you have any questions!

piotrtomiak avatar Jan 15 '16 18:01 piotrtomiak

So, basically you would create a protractor launch configuration delegate, which under the hood in its launch method would just make a call through "tern debugger" framework to appropriate debugger launcher.

I have tried to do that but it doesn't work -( There are no error, but eclipse console displays nothing.

I suppose that it's a problem with ILaunch/IProcess of protractor delegate that it is not used (because I call tern debugger).

angelozerr avatar Jan 15 '16 21:01 angelozerr

We could collaborate on that code, I will help you to get it working. Can you create PR with the stuff you have written and I'll take it over from there?

piotrtomiak avatar Jan 15 '16 22:01 piotrtomiak

We could collaborate on that code, I will help you to get it working.

That's cool:) but forget my last comments, I have found the problem, it works. I will commit soon my work.

After that I will update https://github.com/angelozerr/jsbuild-eclipse to use "tern debugger" and benefit with debug of Grunt/Gulp. I love so this idea with "tern debugger" :) Thank's @piotrtomiak for your contribution about "tern debugger"!

angelozerr avatar Jan 16 '16 10:01 angelozerr

@piotrtomiak you can play with protractor support. Now it creates a Protractor launch that you can customize if you need (choose debugger, node install).

I'm waiting for feedback.

angelozerr avatar Jan 19 '16 07:01 angelozerr

@angelozerr For me, I am not able to see and edit the launch configuration. Also, I think with experience of @Starsk44 the launch configuration is little confusing for users. When a launch config is created it should point to default value, not store it. That's how we did with JavaScript Debug Launch. You can choose to use a default installation (than the field is stored as null) or a particular one, which results in something stored in the launch config.

piotrtomiak avatar Jan 21 '16 12:01 piotrtomiak

@piotrtomiak I have stored value inside launch config protractor, because user want sometimes change debugger, protractor cli file and more add args for protractor (not supported for the moment). So I think it's important to save the launch and user can edit it. No?

angelozerr avatar Jan 21 '16 13:01 angelozerr

Yes, it is, but for me, I couldn't find a protractor launch config anywhere. Something is wrong here. So, maybe it is not good to remove the protractor launch, but rather fix it, so that it shows in run/debug launch configurations.

piotrtomiak avatar Jan 21 '16 13:01 piotrtomiak

Yes, it is, but for me, I couldn't find a protractor launch config anywhere. Something is wrong here.

It is stored inside External Tools (liek Program) and not inside Run/Debug. If you don't like that I can remove the category https://github.com/angelozerr/angularjs-eclipse/blob/master/org.eclipse.angularjs.ui/plugin.xml#L459 to show the launch in the Run/Debug

See https://github.com/angelozerr/angularjs-eclipse/wiki/Protractor#launch-configuration

angelozerr avatar Jan 21 '16 13:01 angelozerr

To be true, I haven't found it there either, but yes I think it is better to place it in the Run/Debug launch configs.

piotrtomiak avatar Jan 21 '16 14:01 piotrtomiak