2

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
[email protected] /home/trki/npm/lib/node_modules/protractor
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected]

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

webdriver-manager update
zsh: command not found: webdriver-manager

3 Answers 3

2

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.)

Sign up to request clarification or add additional context in comments.

5 Comments

Ah lajos! I was just writing an answer to my question because I find out I have to use local node_modules not general. The tests are working now but I am curious what's wrong with this: gist.github.com/TrkiSF2/10993809 (Error: Failed expectation at null) any idea please?
I think this line is the most important: Expected 'Mwuha' to be 'Some fake title'.
and probably the 8. line of your test contains this failed expectation.
Yea sure but it would be nice to have it total functional.The eight line is the expect line but there is something missing with that null and anonymous. One more question. Is there a way to keep it live? watch? without need of starting protractor over and over again with: ./node_modules/protractor/bin/protractor protractor_conf.js ?
The problem is that your test fails. It expects 'Mwuha' and receives 'Some fake title'. Protractor communicates this way the failed tests. And of course it is possible to auto start your tests. For example with grunt-watcher. But protractor tests are relatively slow. I think it is more convenient to run them manually.
1

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.