nathanboktae / mocha-phantomjs-core

Easiest way to run client-side Mocha tests in PhantomJS or SlimerJS :ghost:
MIT License
34 stars 11 forks source link

hangs with slimerjs > 0.9.6 #25

Open yairEO opened 8 years ago

yairEO commented 8 years ago

Using with slimerjs, I manage to run my tests successfully from CMD:

slimerjs mocha-phantomjs-core.js tests.html tap

Slimerjs window opens, I see the a browser window and all seems good, but the CMD doesn't finish. nothing is happening until I close the slimerjs window. I want to output the test result (using TAP reporter) as a file (for jenkins to consume)

is it even possible?

nathanboktae commented 8 years ago

You can either pipe to a file with the shell slimerjs .... > output.tap or use the --file option.

But are your tests hanging or mocha-phantomjs-core?

yairEO commented 8 years ago

I've created a tests2.html file:

<html>
    <head>
        <meta charset="utf-8">
        <link href="mocha.css" rel="stylesheet" />
    </head>
    <body>
        <div id="mocha"></div>
        <script src="../node_modules/mocha/mocha.js"></script>
        <script src="../node_modules/chai/chai.js"></script>
        <script>
            mocha.setup('bdd');
            mocha.ui('bdd');
            var expect = chai.expect;
            var should = chai.should();
            var assert = chai.assert;
        </script>
        <script>
            describe('foo', function(){
                it('bar', function(){
                    'a'.should.eql('a');
                })
            });

            mocha.run();
        </script>
    </body>
</html>

The slimerjs window is open and keeps open, even when the test has passed using

slimerjs mocha-phantomjs-core.js tests2.html > o.tap

o.tap file was created empty

t

yairEO commented 8 years ago

I also now see that system.stderr.writeLine doesn't work on CMD or GIT bash... I've changed mocha-phantomjs-core.js fail function stderr to do stdout instead. now I get the error:

Likely due to external resource loading and timing, your tests require calling window.initMochaPhantomJS() before calling any mocha setup functions. See https://github.com/nathanboktae/mocha-phantomjs-core/issues/12

finally, it was the need to add window.initMochaPhantomJS(); before the setup function.. how silly! all this because I couldn't see any error due to the stderr issue not printed :/

nathanboktae commented 8 years ago

I also now see that system.stderr.writeLine doesn't work on CMD or GIT bash...

Because slimerjs doesn't support it.

What version of slimerjs are you using? I had the tests break and haven't been able to look into it yet so there may have been some contract breakage or regression there.

btw outputing to a file has nothing to do with it. I'm sure if you tried phantomjs2 your tests would run just fine, and you can output the file via those two ways.

yairEO commented 8 years ago

did npm install slimerjs just now so I'm using the latest. Their package.json: "version": "0.906.1"

Regarding your last paragraph, I had nothing but hell using phantomjs for running tests (i'm writing tests and get tons of errors from phantom for them not passing because of variables not defined, like window.cancelAnimationFrame and so on, so I had enough of that and decided to change to slimejs and now everything works great!

(my tests are complex and include testing DOM output so I need a good up-to-date headless browser and i'm not sure phantomjs is as updated as slimerjs in terms of DOM API and latest JS engine)

nathanboktae commented 8 years ago

0.9.6 or 0.906.1 ? that's an odd build number....

yairEO commented 8 years ago

I did npm install then went to \node_modules\slimerjs\package.json scrolled down to version and copy pasted it. it's that number. I also thought it was odd, since it says on the website the latest is 0.10 so I thought maybe they forgot to update the package.json file

nathanboktae commented 8 years ago

Yeah I was using 0.9.6 when I released 4.0 that supported it - see https://travis-ci.org/nathanboktae/mocha-phantomjs-core/jobs/110061074. You may want to install that version to unblock you for now. I'm curious to see if that works for you.

yairEO commented 8 years ago

Changed to 0.9.6 and indeed everything is good, no hanging, and finally things are printed on the terminal. who would have guessed... Thanks :)

nathanboktae commented 8 years ago

Oh this is a big issue - need to fix it, definately not closed :) Thanks for your report and investigation.