Angular-cli: Target e2e suite

Created on 18 May 2016  ·  25Comments  ·  Source: angular/angular-cli

Hey all, I've found that it'd be nice to target a particular test suite with angular-cli.

Something like ng e2e auth instead of editing the angular-cli.json:

"e2e": {
    "protractor": {
      "config": "--suite auth config/protractor.conf.js"
    }
  }

Looks like it'd be pretty easy to pass the proper arguments to the e2e task

Most helpful comment

Its already available in 1.7.0-beta release you can try 1.7.0-beta.3

All 25 comments

Hi,

Any ideas when this will be implemented?
I have multiple scenarios that should run different suites and this fits the bill perfectly!

👍

I don't have an update on when this will be available, but if someone is interested in doing a PR I'll review it.

As a workaround, right now you should be able to do npm run e2e -- --suite auth as well.

I'd really like to knock out this easy little feature (or any angular-cli development), but I'm having trouble with the typings in the angular-cli project.

My recent fork appears to be missing something because I get a lot of errors like:

  • Cannot find module 'fs'
  • Cannot find name 'require'
  • Parameter 'file' implicitly has an 'any' type

@hboylan where do you get those errors? If it's in your editor, it might mean that it doesn't support Typescript 2.0. You should be able to ignore them though, it won't affect much.

@filipesilva the -- workaround to pass extra parameters to protractor doesn't seem to work anymore, I guess because we switched from using the package.json scripts to using directly protractor as a library…

Any idea for another workaround or maybe introduce another way to pass extra parameters to protractors?

@victornoel there isn't a way to pass arbitrary parameters but as far as this issue is concerned now there is a way to pass suites:

ng e2e --specs ./e2e/app.e2e-spec.ts --specs ./e2e/another.e2e-spec.ts

@filipesilva actually specs are not suites :) they are different concepts in protractor!
A suite is a set of specs configured in the protractor configuration.
So technically, this issue is not solved.

Unfortunately for me, my need was to pass an exclude option to protractor, which isn't solved via specs nor suites (I should create another issue for this).

You're absolutely right, and I was confusing the two.

Can you tell me more about your usecase? Is it that you need to exclude specs/suites sometimes only?

@filipesilva here it is:

  • I have a frontend with angular, a backend with java and some other networked resources exploited by the backend.
  • my e2e tests are for the frontend and I run them with mocks to simulate the backend: in that case, all tests can be run as long as my mocks return what is expected.
  • I also want to run the e2e tests with the real backend deployed but without the networked resources (a limitation of our CI and processing resources too): in that case, some of these tests should be disabled, i.e. those pertaining to frontend functionality that relies on the existence of the other networked resources.

I see two ways of solving this need:

  • (current way): in the tests that do need the external resources, I add a keyword in the name and exclude all files containing this keyword when I run the e2e tests with the real backend
  • I could define two suites, one for the e2e tests with backend (so without some of the tests) and one for the mocked frontend

Ok I understand better. Have you considered adding a different protractor config for now?

ng e2e --config mock.protractor.conf.js
ng e2e --config real.protractor.conf.js

I agree that it's not a replacement for a suite flag, but we haven't gotten around to extend the protractor flags further.

I did not think of that, I will see if I can do something with that for now :) Thanks!

Do you want me to open an issue for the exclude flag @filipesilva?

Yes please!

Ditto! I want this!

This would be great - I may be misreading, but it looks like there was already an update for this, marked as superseded though, but I don't think it actually was.

https://github.com/angular/angular-cli/pull/3551

Any update on this? Using the protractor --suite flag would be helpful in our development

Another workaround:
add to package.json :

"scripts": {
.....
"ptor": "protractor"
}

define your suites in protractor.conf.js:

suites: {
    registration: './e2e/app.registration.e2e-spec.ts',
    posting:'./e2e/app.new-post.e2e-spec.ts', './e2e/app.update-post.e2e-spec.ts' ....
     ....
  },

run the desired suite with the double npm option:

npm run ptor -- --suite=posting

npm run e2e -- --suite auth --> this is not working for me. I am using angular cli 1.4.9 and have the below protractor config

exports.config = { suites: { smoke: [ './e2e/**/smoke/**/*.e2e-spec.ts' ], regression: [ './e2e/**/*.e2e-spec.ts' ] }, ... }

@aniruddhadas9 you cannot use it with e2e. Add an extra protractor script command to package.json

"scripts": {
"ptor": "protractor"
}

and run it with npm run ptor -- --suite=smoke

I wanted to run it using angular cli command like ng e2e --suite=smoke. But cli does not pass that flag to protractor. I have also created a pull request in cli to pass the parameter to the protractor pull request

Which version of the cli is this feature (https://github.com/angular/angular-cli/pull/8354) going to be available in ?

Its already available in 1.7.0-beta release you can try 1.7.0-beta.3

Closing as this will be available in 1.7.0.

@filipesilva if I use ng e2e -- --suite auth how do I pass the parameter auth to protractor.conf.js

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NCC1701M picture NCC1701M  ·  3Comments

jmurphzyo picture jmurphzyo  ·  3Comments

rajjejosefsson picture rajjejosefsson  ·  3Comments

brtnshrdr picture brtnshrdr  ·  3Comments

naveedahmed1 picture naveedahmed1  ·  3Comments