koolth / generator-bourbon-neat

Yeoman generator for a website using thoughtbot's Bourbon Neat. Options for Normalize and Modernizr!
MIT License
34 stars 5 forks source link

PhantomJS Timeout #9

Open samfearn opened 8 years ago

samfearn commented 8 years ago

Hey,

I've just tried to scaffold out a project using this generator, but if I try to run `grunt' from within the working directory the grunt task fails with the error:

"Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue. Aborted due to warnings.

When I look at the directory structure I can see that I don't actually have a /test folder, just /app/, /bower_components/, /node_modules/, /package.json, /bower.json and Gruntfile.js.

For what its worth, when I ran 'yo' to scaffold out the project I got

phantomjs@1.9.19 install /Users/sam/Development/remoteLED/node_modules/phantomjs node install.js

PhantomJS not found on PATH ... Writing location.js file Done. Phantomjs binary available at /~/Development/remoteLED/node_modules/phantomjs/lib/phantom/bin/phantomjs

samfearn commented 8 years ago

Ok, I've been playing with this on and off during the day, but I'm very new to using grunt, bower, yo etc, so I may be saying things that are either obvious or stupid.

At this point it all seems to be working. The test runs (obviously there are no actual tests being run and the test index.html has nothing to do with the app index.html) and the grunt task completes.

test index.html for reference:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Example Mocha Test</title>
    <link rel="stylesheet" href="../node_modules/mocha/mocha.css" type="text/css" charset="utf-8" />
</head>
<body>
    <!-- Required for browser reporter -->
    <div id="mocha"></div>

    <!-- mocha -->
    <script src="../node_modules/mocha/mocha.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
        // This will be overridden by mocha-helper if you run with grunt
        mocha.setup('bdd');
    </script>

    <!-- Include your assertion lib of choice -->
    <script src="../node_modules/chai/chai.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
        // Setup chai
        var expect = chai.expect;
    </script>

    <!-- run mocha -->
    <script type="text/javascript" charset="utf-8">
        // If tests run in a real browser
        // Can alternatively do a check on window.PHANTOMJS
        if (navigator.userAgent.indexOf('PhantomJS') < 0) {
            mocha.run();
        }
    </script>
</body>
</html>
samfearn commented 8 years ago

This leaves the problem of getting real tests working. So far I've added the script test1.js to test/spec/test1.js

'use strict';
describe('Array', function(){
  describe('#indexOf()', function(){
    it('should return -1 when the value is not present', function(){
      chai.assert.equal(-1, [1,2,3].indexOf(5));
      chai.assert.equal(-1, [1,2,3].indexOf(0));
    });
  });
});

Getting this through jshint required me to add "mocha": true" and '"predef":["chai"]` to my .jshintrc.