Skip to content
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

e2e test doesn't work with multiCapabilities #975

Closed
PhilippSoehnlein opened this issue Jun 1, 2016 · 9 comments · Fixed by #6255
Closed

e2e test doesn't work with multiCapabilities #975

PhilippSoehnlein opened this issue Jun 1, 2016 · 9 comments · Fixed by #6255
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix

Comments

@PhilippSoehnlein
Copy link

The main goal I try to achieve is to run the e2e tests of an angular-cli generated app on multiple browsers which currently fails because as soon as I add a second browser I get Unexpected token import errors when I run tests.

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Mac OS X El Capitan (10.11.4).

  1. Versions. Please run ng --version. If there's nothing outputted, please
    run in a Terminal:
    node --version
    And paste the result here.
$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.5
node: 5.9.1
os: darwin x64
$ node --version
v5.9.1
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
  • Create an app with angular-cli: ng new testfoo
  • Change protractor.conf.js like this to make tests run in multiple browsers:
diff --git a/config/protractor.conf.js b/config/protractor.conf.js
index 57f4f87..76b4df8 100644
--- a/config/protractor.conf.js
+++ b/config/protractor.conf.js
@@ -6,9 +6,10 @@ exports.config = {
   specs: [
     '../e2e/**/*.e2e.ts'
   ],
-  capabilities: {
-    'browserName': 'chrome'
-  },
+  multiCapabilities: [
+    { 'browserName': 'chrome' },
+    { 'browserName': 'firefox' }
+  ],
   directConnect: true,
   baseUrl: 'http://localhost:4200/',
   framework: 'jasmine',
  1. The log given by the failure. Normally this include a stack trace and some more information.
$ ng serve &
$ ng e2e
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.

> testfoo@0.0.0 pree2e /Users/u1235/tmp/angularclitest/testfoo
> webdriver-manager update

selenium standalone is up to date.
chromedriver is up to date.

> testfoo@0.0.0 e2e /Users/u1235/tmp/angularclitest/testfoo
> protractor "config/protractor.conf.js"

[14:02:58] I/launcher - Running 2 instances of WebDriver
[14:02:59] I/testLogger -
------------------------------------

[14:02:59] I/testLogger - [chrome #01] PID: 4694
[chrome #01] Specs: /Users/u1235/tmp/angularclitest/testfoo/e2e/app.e2e.ts
[chrome #01]
[chrome #01] [14:02:58] I/direct - Using ChromeDriver directly...
[chrome #01] [14:02:59] I/runnerCli - Unexpected token import

[14:02:59] I/testLogger -

[14:02:59] E/launcher - Runner process exited unexpectedly with error code: 1
[14:02:59] I/launcher - 1 instance(s) of WebDriver still running
[14:03:00] I/testLogger -
------------------------------------

[14:03:00] I/testLogger - [firefox #11] PID: 4695
[firefox #11] Specs: /Users/u1235/tmp/angularclitest/testfoo/e2e/app.e2e.ts
[firefox #11]
[firefox #11] [14:02:58] I/direct - Using FirefoxDriver directly...
[firefox #11] [14:03:00] I/runnerCli - Unexpected token import

[14:03:00] I/testLogger -

[14:03:00] E/launcher - Runner process exited unexpectedly with error code: 1
[14:03:00] I/launcher - 0 instance(s) of WebDriver still running
[14:03:00] I/launcher - chrome #01 failed with exit code: 1
[14:03:00] I/launcher - firefox #11 failed with exit code: 1
[14:03:00] I/launcher - overall: 2 process(es) failed to complete
[14:03:00] E/launcher - Process exited with error code 100

Some end-to-end tests failed, see above.

5. Mention any other details that might be useful.

Interestingly it works if multiCapabilities is used with only one browser, no matter which.

@PhilippSoehnlein PhilippSoehnlein changed the title e2e test don't work with multiCapabilities e2e test doesn't work with multiCapabilities Jun 1, 2016
@filipesilva filipesilva added type: bug/fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jun 2, 2016
@raymondkarstensen
Copy link

Had the same problem, but fixed it by adding the following to protractor.conf.js
onPrepare: function () { require('ts-node').register({ project: 'e2e' }); }

@PhilippSoehnlein
Copy link
Author

@raymondkarstensen Thanks, that works for me.

@filipesilva
Copy link
Contributor

How odd... we already have require('ts-node').register({ project: 'e2e' }); in the beforeLaunch callback, which according to https://github.com/angular/protractor/blob/master/docs/referenceConf.js#L223-L227 should run before onPrepare. I need to investigate this further.

@filipesilva filipesilva self-assigned this Jun 7, 2016
@raymondkarstensen
Copy link

Actually I moved it from beforeLaunch to onPrepare.

@chrischiang410
Copy link

Had the same problem, too.
After moving require('ts-node').register({ project: 'e2e' }) from beforeLaunch to onPrepare, Protractor worked fine with multiple browser finally!
Thanks @raymondkarstensen

@hansl hansl modified the milestone: RC1 Nov 11, 2016
@hansl hansl removed this from the RC1 milestone Mar 16, 2017
@aniruddhadas9
Copy link
Contributor

moving from onPrepare is also worked for me. More over I am using sauce lab to test my test cases and now its able to connect to sauce lab and start testing.

@angular/cli: 1.0.0-rc.1
node: 6.9.1
os: darwin x64

onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
}

@kevcjones-archived
Copy link

I can confirm using browserstack local + multiCapabilities i had the same issue. I turned off direct connect too from some console complaining it did.

@angular/cli 1.0.0
node: 6.9.5
El Capitan 10.11.5

Same as @raymondkarstensen, moving to the Prepare stage worked a treat. Is there a consequence to this?

@micahwood
Copy link

It looks like this is the key reason for needing it in onPrepare when using multiCapabilities.

If multiple capabilities are being run, this will run once per capability

https://github.com/angular/protractor/blob/master/lib/config.ts#L407

beforeLaunch only runs once and only once, so I'm guessing each capability requires it's own typescript compiler.

filipesilva added a commit to filipesilva/angular-cli that referenced this issue May 10, 2017
filipesilva added a commit that referenced this issue May 10, 2017
sumitarora pushed a commit that referenced this issue May 15, 2017
sumitarora pushed a commit that referenced this issue May 18, 2017
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants