Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for mocha-given doesn't run #4

Closed
wants to merge 2 commits into from
Closed

Test for mocha-given doesn't run #4

wants to merge 2 commits into from

Conversation

TheLudd
Copy link

@TheLudd TheLudd commented Jul 13, 2014

I tried cloning the mocha-given repo and run the tests but it didn't work for me. I get this error:

/usr/local/lib/node_modules/mocha/lib/mocha.js:139
  if (!this._ui) throw new Error('invalid interface "' + name + '"');
                       ^
Error: invalid interface "mocha-given"
    at Mocha.ui (/usr/local/lib/node_modules/mocha/lib/mocha.js:139:24)
    at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:188:7)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Here is a fix for it. I have create a test runner acording to the instructions in the readme file for mocha-given. I changed the npm test command to use the test runner. I also added mocha as a local dependency since this will make the tests independent of global installs on the machine that runs them.

@TheLudd
Copy link
Author

TheLudd commented Jul 13, 2014

Don't know what the error is about. When I go to travis, it seems to be passing...

@tandrewnichols
Copy link
Collaborator

Try cd node_modules/mocha-given && npm install. I've run into similar issues and the cause is always that dependencies for mocha-given weren't installed because npm thought they were already satisfied elsewhere.

@TheLudd
Copy link
Author

TheLudd commented Jul 14, 2014

@tandrewnichols At what root folder? The project mocha-given doesn't have a node module mocha-given and nor should it right?

@rendro
Copy link
Owner

rendro commented Jul 14, 2014

Another easy way is to symlink the mocha-given lib into the node_modules folder. I'll post this ASAP and add a script to the package.json

And mocha given should not have any dependencies next to coffee-script. Mocha itself is a peer dependency. To test mocha-given you'll have to manually install it. The purpose is that used in a project, mocha-given should not add overhead to the project - but it makes it harder to jump on developing mocha-given.

I'll also add a short description to the readme to clarify things.

@TheLudd
Copy link
Author

TheLudd commented Jul 14, 2014

@rendro Well technically I didn't add it as a dependency but as a devDependency which allows mocha-given to be tested independent of the global environment. If mocha 2.0.0 were to be released with breaking changes, the local version of mocha when developing mocha-given would still be the one specified in package.json and it coul be increased at the projects own pace.

That being said I think that the most important thing is that the tests should always run correctly when executing npm test. The reason I did this was that I was looking at helping out with #2 and I couldn't even get the test to run. So this was my take on a solution for that...

@rendro
Copy link
Owner

rendro commented Jul 14, 2014

Mocha is references as a peer dependency to avoid problems once mocha releases a newer version with breaking changes. Furthermore mocha-given itself should only be added as a devDependency because tests are only for development and not production.

Now, after following the instructions in the readme, you can run the tests with npm test and start developing 👍

@rendro rendro closed this Jul 14, 2014
@TheLudd
Copy link
Author

TheLudd commented Jul 14, 2014

Ok, I guess that works. Just note that the guy that wrote the article you linked to also created Chai as pormised. That lib has chai as a peer dependency and as a dev dependency. It also has a bunch of dev dependencies and no regular dependencies. Installing chai-as-promised only installs one other lib and that is the peer dependency. So adding mocha as a devDependency does not add overhead to users of mocha-given.

@rendro
Copy link
Owner

rendro commented Jul 14, 2014

Thanks! The problem again is how to enable mocha to load mocha-given as a dependency when it is the current directory, because mocha looks for mocha-given in the node_modules folder but not in the root directory. Do you know a good article on how the dependency installing works with npm in detail? When are devDependencies being loaded and when not and stuff like that?

@TheLudd
Copy link
Author

TheLudd commented Jul 14, 2014

Only place I have read about it is in the docs (you need to search for the headline devDependencies). But basically, devDependencies are only installed when you work with your lib. They are not installed as sub dependencies when other people depend on your package.

And if mocha-given is not in the node_modules folder you can load it manually as I did in runtests.coffee in my pull request. I found the info for that in you readme file =)

@rendro
Copy link
Owner

rendro commented Jul 14, 2014

Yes, I know, but I don't like the idea to load all the tests programmatically if it also works with the symlink solution. It is closer to the actual use.

So we should add mocha as a devDependency as well to facilitate the development process!

@TheLudd
Copy link
Author

TheLudd commented Jul 14, 2014

It is of course up to you. Adding mocha as a devDependency will get rid of the step you have in your readme right now saying

Afterwards mocha has to be installed with $ npm install mocha.

I am not sure how the symlink will work across different operating systems. Not that I am a big fan of windows though...

@rendro
Copy link
Owner

rendro commented Jul 14, 2014

Yeah, it won't work on windows, thats true. There is a native npm link operation that links the current module into the global node_modues folder (I guess it works on win), but when I tried it out, mocha again could not resolve the UI :(

@tandrewnichols
Copy link
Collaborator

@TheLudd I misunderstood what you were saying I think. But it looks like you've resolved it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants