GruntBlanketMocha / grunt-blanket-mocha

Headless Blanket.js code coverage and Mocha testing via PhantomJS
MIT License
53 stars 37 forks source link

Incompatible with Mocha 1.1.4+ #12

Closed cbullen closed 10 years ago

cbullen commented 10 years ago

The following exception prevents tests running:

[Error] TypeError: 'undefined' is not a function (evaluating 'self.suiteURL(suite)')
    (anonymous function) (mocha.js, line 2585)
    emit (mocha.js, line 588)
    runSuite (mocha.js, line 4720)
    next (mocha.js, line 4725)
    next (mocha.js, line 4663)
    runTests (mocha.js, line 4699)
    (anonymous function) (mocha.js, line 4737)
    next (mocha.js, line 4514)
    (anonymous function) (mocha.js, line 4538)
    timeslice (mocha.js, line 5531)

TestRunner:

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

    <!-- mocha -->
    <script src="../node_modules/grunt-blanket-mocha/node_modules/mocha/mocha.js" type="text/javascript" charset="utf-8"></script>
    <script src="../node_modules/blanket/dist/mocha/blanket_mocha.js" data-cover-adapter="../node_modules/blanket/src/adapters/mocha-blanket.js"></script>
    <script>
        // If tests are run in PhantomJS.
        if (navigator.userAgent.indexOf('PhantomJS') !== -1) {
          blanket.options("reporter", "../node_modules/grunt-blanket-mocha/support/grunt-reporter.js");
        }
    </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">
        // This will be overridden by mocha-helper if you run with grunt
        mocha.setup('bdd');
    </script>
    <script type="text/javascript" charset="utf-8">
        // Setup chai
        var expect = chai.expect;
    </script>

    <!-- Test -->
    <script src="Cow/Cow.js" data-cover type="text/javascript" charset="utf-8"></script>
    <script src="Cow/CowTest.js" type="text/javascript" charset="utf-8"></script>

    <!-- run mocha -->
    <script type="text/javascript" charset="utf-8">
        // If tests run in a real browser.
        if (navigator.userAgent.indexOf('PhantomJS') === -1) {
            mocha.run();
        }
    </script>
</body>
</html>

This plugin appears to be incompatible with Mocha 1.1.4 (the listed dependency). The exception does not occur when Mocha 1.1.3 is used.

  "devDependencies": {
    "grunt": "~0.4.2",
    "chai": "~1.8.1",
    "blanket": "~1.1.5",
    "grunt-blanket-mocha": "~0.3.3"
  }
geekdave commented 10 years ago

Thanks for reporting, @cbullen! This is actually not a bug with this plugin, but rather in BlanketJS itself.

This has been resolved in BlanketJS https://github.com/alex-seville/blanket/pull/356 which is not yet part of a released version. So you can work around this by using an older version of Mocha, or using the master version of BlanketJS.

I will add a note to the README in the meantime.

cbullen commented 10 years ago

Awesome. Thanks!

peter-mouland commented 10 years ago

I've noticed that the parent project has fixed this issue and was hoping you could git pull upstream? I'm happy to do my own pull request if you wish but didn't want to charge in and take credit @perfectworks work!

https://github.com/kmiyashiro/grunt-mocha/pull/92/files

geekdave commented 10 years ago

@peter-mouland Awesome! Thanks for finding this. A PR would be most appreciated, as I won't be able to get to this for awhile.