-
Notifications
You must be signed in to change notification settings - Fork 73
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
Updated Mocha documentation #6
Comments
It looks like I forgot to update the release note with the mocha changes - sorry, however the example you pasted (and those in the examples folder) are correct. They work for me if I clone master and run
So my guess is there's a problem with your scenario or the library. Can you paste both please? PS responses might be a little slow as I'm on holiday in a cottage with very unreliable wifi! |
No worries, I have not been near the computer for a few days either. I have renamed some of the stuff, as I am just prototyping at the moment, but here is all the code required. It basically uses your example but a different directory structure, kicked off by a jake build script.
Finally the jake task which kicks all this off:
|
I created a new node 0.10.8 (and also 0.10.15) project based on the above example and pulled in the follow dependencies... "dependencies": {
"yadda": "~0.4.4",
"mocha": "~1.12.0"
} I've tried running mocha from the command line (I had to change the directory from tests to test) and also from a script var Mocha = require('Mocha');
var mochaRunner = new Mocha;
mochaRunner.addFile('test/acceptance/example-tests.js')
mochaRunner.reporter("spec").run(); but not from jake. The test passed both times
Maybe the problem is os related? I'm using Mountain Lion, but will try with Ubuntu too. |
It's OK on ubuntu too |
:( Im one of those windows users, I presume it should still all work ok. I will try cloning and just testing on yours directly on the system just to make sure it is nothing with my setup. |
In that case maybe it's to do with line endings. The scenario parser (lib/parsers/TextParser) splits the lines in the scenario using /\n/, and maybe this should be /\r?\n/. I'll fire up a windows VM tomorrow and test it. |
Just tried in a Windows 8 VM
Would be interested to see what happens if you try the same |
Right! after realising that your "node" above must be the node command line rather than the normal command line I ran the steps above, and if I run mocha directly:
So mocha runs, then I went to try your example above, and got the following output:
So get the same issue running against your test examples |
even more info, right as I am working on the source code directly now, I have realised that you are expecting the files as UTF8. However the files come as ANSI, so whenever you try to load them it just blows up as it is not in the right format. If I use Notepad++ and convert the feature text file to UTF8 then it still blows up, so if I take out the UTF-8 argument and leave it encoding-less then it gets as far as this:
Weird thing is if I console.log(text); I see the file contents, but something in the parsing phase must blow up. Using Node 0.10.13. |
It seems like the regex isnt hitting the lines properly for some reason, I went and used rubular and that seemed fine with them, however if I sprinkle console.log statements throughout I get the following outputs:
I basically put the following in the parse_line method:
So the issue is because the scenarios and steps do not appear to get picked up, so when it goes to assign the steps, it is empty so the push will throw an exception. Like shown in the original errors. So I would assume if the scenario matches (like it should) then the steps will already exist to be populated... |
If I remove the $ symbol (end of line) from the end of the 2 regex expressions then it all works, and I get 2 passes, so I can only assume that there is some inconsistency between the line endings, although I assume the regex would just know what to do based on the OS. I am not sure if this has any negative effects, as you are always receiving a single line to this method anyway, so it shouldn't matter... |
I agree. I'll make the change and push a new release out. Thanks for your efforts! |
0.4.5 pushed to npm. If you can confirm this fixes the problem I'll close the issue. Once again thanks. |
Will go check it now, thanks for your help, im glad it was something simple. |
Seems to have fixed it, thanks for your help. |
You mention that in the latest version there are breaking changes, but there is no documentation I can find around this. I know there are examples to look at in the repo, however they dont seem to work for me, I keep getting:
When following the examples, so are the examples up to date and if not could the documentation reflect this? If however they are up to date examples any ideas whats causing the issue above?
The code being used is:
I assume its the require("yadda").plugins.mocha() but dont know specifically what will be causing it.
The text was updated successfully, but these errors were encountered: