Experience-Monks / devtool

[OBSOLETE] runs Node.js programs through Chromium DevTools
MIT License
3.77k stars 150 forks source link

Run Mocha test #40

Closed zzarcon closed 8 years ago

zzarcon commented 8 years ago

I'm trying to use devtool with mocha.js but i get this error:

module.js:340
    throw err;
    ^

Error: Cannot find module '/usr/local/Cellar/nvm/0.26.1/v0.10.39/lib/node_modules/devtool/node_modules/electron-prebuilt/dist/Electron.app/Contents/Frameworks/Electron Helper.app/Contents/Resources/atom.asar/browser/lib/init.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:289:25)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:151:18)
    at node.js:1007:3

I'm using the 1.7.6 version and trying:

$ devtool /usr/local/opt/nvm/v0.10.39/bin/mocha `$ devtool /usr/local/opt/nvm/v0.10.39/bin/mocha --opts test/mocha.opts 'test/*/.spec.js'``

Both times i get the same error. I'm doing something wrong? thanks!

mattdesl commented 8 years ago

Any chance you can put together a small test case? I've never used mocha before.

zzarcon commented 8 years ago

Sure, I created a dummy repo just to show the error.

https://github.com/zzarcon/mocha-electron-error

I tried also with absolute paths but don't work:

$ /usr/local/opt/nvm/v0.10.39/bin/devtool /usr/local/opt/nvm/v0.10.39/bin/mocha

zzarcon commented 8 years ago

For some reasons is unable to find the init.js file

mattdesl commented 8 years ago

I just ran your test through devtool and it seemed to work fine for me. Here's the command I ran from your repo:

devtool ./node_modules/mocha/bin/_mocha -qc -- ./test/dummy-spec.js 

(Note: Mocha seems to quit the process when all tests finish!)

That is a strange error, maybe it got corrupted during install? You can re-install globally like so:

npm install devtool -g

Also which platform are you on? npm version? I'm also not sure if node version matters but I've been testing on node@5.

zzarcon commented 8 years ago

Ok, so doing

devtool ./node_modules/mocha/bin/_mocha

Works for me! My problem was that I was trying to run it like

devtool ./node_modules/mocha/bin/mocha and $ devtool ./node_modules/.bin/mocha which is basically the same.

I tried reinstalling devtool globally again and using node@5 but still fails using my approach... So maybe is this something expected and simply I didn't know how to use it properly? or it's a bug of the mocha cli?

Thanks very much for the help

mattdesl commented 8 years ago

Sadly the mocha script spawns a new process which means we can't easily debug it, which is why _mocha is used instead. More discussion: https://github.com/s-a/iron-node/issues/51

zzarcon commented 8 years ago

I see, i will close the issue now since there's nothing wrong with Devtool ^^

Thanks for the info :muscle:

mattdesl commented 8 years ago

Added this to the readme under Grunt/Gulp/Mocha section. :smile: