Question

I spent all day trying to setup test setup for angularJS. I had generated angular app with yo angular and then I modified grunt conf file like so:

// Test settings
karma: {
  e2e: {
   configFile: 'karma-e2e.conf.js'
  },
  unit: {
    configFile: 'karma.conf.js'
  }
}

Carma config file: https://gist.github.com/TrkiSF2/10919353

karma e2e conf file: https://gist.github.com/TrkiSF2/10919425

The unit tests work (grunt karma:unit) but I don't know how to setup e2e tests and after all day I am pretty desperate.

First I should setup a protractor right? (plus I would probably like to setup phantomJs as well? so the browser will not open always)

I had reinstalled node today few times...

I came here: https://github.com/angular/protractor/blob/master/docs/getting-started.md

and tried to install protractor

npm http 304 https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/lru-cache
/home/trki/npm/bin/protractor -> /home/trki/npm/lib/node_modules/protractor/bin/protractor
/home/trki/npm/bin/webdriver-manager -> /home/trki/npm/lib/node_modules/protractor/bin/webdriver-manager
protractor@0.21.0 /home/trki/npm/lib/node_modules/protractor
├── saucelabs@0.1.1
├── q@1.0.0
├── minijasminenode@0.2.7
├── adm-zip@0.4.4
├── lodash@2.4.1
├── optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.8)
├── glob@3.2.9 (inherits@2.0.1, minimatch@0.2.14)
└── selenium-webdriver@2.40.0

And from this point I am lost. What to do next?

webdriver-manager update
zsh: command not found: webdriver-manager
Was it helpful?

Solution 3

I could not solve this issue using protractor as general command. However I solved it via LOCAL node_modules as Lajos Veres in previous answer pointed out.

This amazing tutorial nicely shows how to setup (locally) and use protractor.

 npm install protractor

./node_modules/protractor/bin/webdriver-manager update

And for configuring protractor check out the well written tutorial.

OTHER TIPS

You should use full path to call webdriver-manager. It is in one of the node_modules directories:

node_modules/protractor/bin/webdriver-manager update

And this is true as well for protractor:

node_modules/protractor/bin/protractor configfile

(protractor won't do too much without a config file. You should create it one first and tests as well.)

You can find a good prebuil/example environment here: https://github.com/angular/angular-seed

(Actually for me this project needed this setting: npm config set strict-ssl false and I had to remove the ^~ characters from the version numbers in the package.json file, but otherwise it contains good example configs/settings/test skeletons.)

You could try to follow this guide: How to set up Angular e2e testing - Protractor. It seems to explain it from scratch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top