cognoma / frontend

Frontend for Project Cognoma
http://cognoma.org/
Other
4 stars 22 forks source link

Unit Test: basic unit tests for existing application components #29

Closed bdolly closed 7 years ago

bdolly commented 7 years ago

Need to write base unit tests for existing components:

Also need to integrate unit test runner into npm run dev task so that unit tests are ran on each save while developing

bdolly commented 7 years ago

@awm33 can you take a look at the develop branch testing setup. It is based on https://github.com/jakemmarsh/angularjs-gulp-browserify-boilerplate#testing-1 setup for unit and e2e test and advise if this is a good testing setup to move forward with as I don't have much experience in this area

awm33 commented 7 years ago

@bdolly That's looking good. Were you able to get working with Selenium?

bdolly commented 7 years ago

@awm33 Yeah I think so? I did some googling and ended up brew installing JRE which resolved some issue with it

awm33 commented 7 years ago

Trying to run the tests myself locally, I get "Error: Cannot find module 'ui-router-route-to-components' from '/Users/amadonna/Documents/frontend/app/js'"

Full console

Andrews-MacBook-Pro:frontend amadonna$ npm run protractor

> Cognoma@0.0.0 protractor /Users/amadonna/Documents/frontend
> cross-env NODE_ENV=test ./node_modules/.bin/gulp protractor

[14:27:30] Requiring external module babel-register
[14:27:32] Using gulpfile ~/Documents/frontend/gulpfile.babel.js
[14:27:32] Starting 'clean'...
[14:27:32] Starting 'webdriverUpdate'...
[14:27:32] Starting 'webdriver'...
[14:27:32] Finished 'webdriver' after 201 μs
[14:27:32] Finished 'clean' after 19 ms
[14:27:32] Starting 'prod'...
[14:27:32] Starting 'styles'...
[14:27:32] Starting 'images'...
[14:27:32] Starting 'fonts'...
[14:27:32] Starting 'views'...
[14:27:32] Finished 'fonts' after 24 ms
[14:27:32] Finished 'views' after 140 ms
[14:27:33] I/file_manager - creating folder /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium
[14:27:33] I/downloader - selenium standalone: downloading version 2.53.1
[14:27:33] I/downloader - curl -o /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-2.53.1.jar https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
[14:27:33] I/downloader - chromedriver: downloading version 2.24
[14:27:33] I/downloader - curl -o /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.24mac64.zip https://chromedriver.storage.googleapis.com/2.24/chromedriver_mac64.zip
[14:27:33] I/downloader - geckodriver: downloading version v0.9.0
[14:27:33] I/downloader - curl -o /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.9.0-mac.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.9.0/geckodriver-v0.9.0-mac.tar.gz
[14:27:33] Finished 'styles' after 539 ms
[14:27:33] gulp-imagemin: Minified 3 images (saved 53.66 kB - 69.8%)
[14:27:33] Finished 'images' after 523 ms
[14:27:33] Starting 'browserify'...
[14:27:33] Rebundling...
[14:27:35] I/update - geckodriver: unzipping /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.9.0-mac.tar.gz
[14:27:35] I/update - geckodriver: setting permissions to 0755 for /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.9.0
[14:27:36] Error: Cannot find module 'ui-router-route-to-components' from '/Users/amadonna/Documents/frontend/app/js'

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "protractor"
npm ERR! node v6.1.0
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! Cognoma@0.0.0 protractor: `cross-env NODE_ENV=test ./node_modules/.bin/gulp protractor`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the Cognoma@0.0.0 protractor script 'cross-env NODE_ENV=test ./node_modules/.bin/gulp protractor'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Cognoma package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=test ./node_modules/.bin/gulp protractor
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs Cognoma
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls Cognoma
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/amadonna/Documents/frontend/npm-debug.log
Andrews-MacBook-Pro:frontend amadonna$ [14:27:40] I/update - chromedriver: unzipping /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.24mac64.zip
[14:27:40] I/update - chromedriver: setting permissions to 0755 for /Users/amadonna/Documents/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.24

Node.js - v6.1.0 NPM - 3.8.6

bdolly commented 7 years ago

@awm33 looks like I forgot to pass --save-dev flag when I installed that module. If you run $npm i ui-router-route-to-components --save-dev to install that module it should clear up that error.

bdolly commented 7 years ago

@awm33 adding the proper package.json in https://github.com/cognoma/frontend/pull/35

bdolly commented 7 years ago

added unit test runner into $npm run dev task with #35

bdolly commented 7 years ago

closing as task is too vague