Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Start implementing browser tests using karma #78

Closed
wants to merge 10 commits into from

Conversation

dignifiedquire
Copy link
Contributor

Ref #77

  • Travis happy
    • test:node
    • test:browser
  • Use Karma :)
  • refactor tests to pass in nodejs environment
  • add saucelabs (or similar) integration (account created, need to configure it now)

@dignifiedquire
Copy link
Contributor Author

@victorbjelkholm nearly done with all your listed todos ;)

@dignifiedquire
Copy link
Contributor Author

At the moment the test:browser script fails on travis because it can not run node_modules/.bin/ipfs daemon for some reason. If anyone has an idea please help, I'm at a loss here

@jbenet
Copy link
Contributor

jbenet commented Oct 19, 2015

i dont see the logging output from ipfs but i would suspect a port clash

@dignifiedquire
Copy link
Contributor Author

All done @diasdavid @victorbjelkholm please give this a code review :)

@@ -0,0 +1,75 @@
module.exports = function (config) {
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need this to be able to run in local? I think this should be optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, not sure of the best way to do that, suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract the SauceLabs specific parts that only get added if process.env.SAUCE_USERNAME and SAUCE_ACCESS_KEY is set would be a simple way to achieve it.

@dignifiedquire dignifiedquire changed the title Start implementing browser tests using karma [do not merge] Start implementing browser tests using karma Oct 21, 2015
@daviddias
Copy link
Contributor

this is awesome! Thank you @dignifiedquire and @victorbjelkholm ! :D

I'm getting 2 tests fail though, one might be related with being in a slow wifi, but the other (when daemon stops) shouldn't throw. Am I the only one seeing this?

» npm test                                                                                                                                       ◉ ◼◼◼◼◼◼◼◼◼◼

> [email protected] test /Users/david/Documents/code/ipfs/node-ipfs-api
> npm run test:node && npm run test:browser


> [email protected] test:node /Users/david/Documents/code/ipfs/node-ipfs-api
> mocha



  ipfs node api
    # ipfs node setup
    # ipfs init done
    # ipfs daemon running
    ✓ has the api object
    ✓ add file
    ✓ add buffer
    - add path
    ✓ cat
    1) ls
    ✓ config set/get
    ✓ block.put
    ✓ block.get
    ✓ object.put
    ✓ object.get
    ✓ object.data
    - refs
    ✓ id
    - returns an error when getting a non-existent key from the DHT
    - puts and gets a key value pair in the DHT
    2) test for error after daemon stops


  11 passing (16s)
  4 pending
  2 failing

  1) ipfs node api ls:
     Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.


  2) ipfs node api test for error after daemon stops:
     Error: the object {
  "Code": 0
  "Message": "context canceled"
  "uncaught": true
} was thrown, throw an Error :)





npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/iojs" "/usr/local/bin/npm" "run" "test:node"
npm ERR! node v4.2.0
npm ERR! npm  v3.3.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test:node: `mocha`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] test:node script 'mocha'.
npm ERR! This is most likely a problem with the ipfs-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mocha
npm ERR! You can get their info via:
npm ERR!     npm owner ls ipfs-api
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/david/Documents/code/ipfs/node-ipfs-api/npm-debug.log
npm ERR! Test failed.  See above for more details.

@dignifiedquire
Copy link
Contributor Author

@diasdavid run them a couple of times, no idea they sometimes work and sometimes fail for me I think it's not dependent on this api but rather on ipfs answering fast enough. Maybe the daemon checks should be separated out or so.

@daviddias
Copy link
Contributor

Question posted on IRC:

14:09 <+daviddias> dignifiedquire: I'm not being able to understand why the 'add path' test stays on 'pending' state
14:09 <+daviddias> seems that tests are being executed in parallel now 
14:09 <+daviddias> and since others fail, that one doesn't even finish

Also, running npm run test:browser throws because it is not using a disposable Node:

» npm run test:browser                                                                                                                          ◉ ◼◼◼◼◼◼◼◼◼◻

> [email protected] test:browser /Users/david/Documents/code/ipfs/node-ipfs-api
> ipfs init && API_ORIGIN="*" ./node_modules/.bin/concurrent --kill-others "./node_modules/.bin/ipfs daemon" "./node_modules/.bin/karma start --single-run=true karma.conf.js"

initializing ipfs node at /Users/david/.ipfs
Error: ipfs configuration file already exists!
Reinitializing would overwrite your keys.
(use -f to force overwrite)


npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/iojs" "/usr/local/bin/npm" "run" "test:browser"
npm ERR! node v4.2.0
npm ERR! npm  v3.3.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test:browser: `ipfs init && API_ORIGIN="*" ./node_modules/.bin/concurrent --kill-others "./node_modules/.bin/ipfs daemon" "./node_modules/.bin/karma start --single-run=true karma.conf.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:browser script 'ipfs init && API_ORIGIN="*" ./node_modules/.bin/concurrent --kill-others "./node_modules/.bin/ipfs daemon" "./node_modules/.bin/karma start --single-run=true karma.conf.js"'.
npm ERR! This is most likely a problem with the ipfs-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ipfs init && API_ORIGIN="*" ./node_modules/.bin/concurrent --kill-others "./node_modules/.bin/ipfs daemon" "./node_modules/.bin/karma start --single-run=true karma.conf.js"
npm ERR! You can get their info via:
npm ERR!     npm owner ls ipfs-api
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/david/Documents/code/ipfs/node-ipfs-api/npm-debug.log

@daviddias
Copy link
Contributor

@dignifiedquire @victorbjelkholm would you mind if I add a branch to node-ipfs-api that we all can work in (giving you perm) to do the PR to master, so that we don't have to create forks to PR into @dignifiedquire fork so that it gets PR'ed into master?

@dignifiedquire
Copy link
Contributor Author

sure thing

@daviddias
Copy link
Contributor

Awesome! :) Check #81

closing this one :)

@daviddias daviddias closed this Oct 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants