Browser tdd: describe is not defined; bdd is ok

373 views
Skip to first unread message

ascani...@gmail.com

unread,
Jun 9, 2016, 9:21:56 AM6/9/16
to Mocha
Weird situation: set up  yeoman with backbone generator

yo backbone

with mocha.setup("bdd")  the tests run

with mocha.setup("tdd") getting ReferenceError: describe is not defined.

Any suggestions? Thanks.

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Mocha Spec Runner</title>
  <link rel="stylesheet" href="../bower_components/mocha/mocha.css">
</head>
<body>
  <div id="mocha"></div>
  <script src="../bower_components/jquery/dist/jquery.js"></script>
  <script src="../bower_components/underscore/underscore.js"></script>
  <script src="../bower_components/backbone/backbone.js"></script>
  <script src="../bower_components/mocha/mocha.js"></script>
  <script>mocha.setup('tdd');// works with "bdd"</script>
 
  <script src="../bower_components/chai/chai.js"></script>
  <script>
    var assert = chai.assert;
    var expect = chai.expect;
    var should = chai.should();
  </script>
  <!-- bower:js -->
  <!-- endbower -->
  <!-- include source files here... -->
  <!-- include spec files here... -->
  <script src="spec/test.js"></script>
  <script>
    if (navigator.userAgent.indexOf('PhantomJS') === -1) {
      mocha.run();
    }
  </script>
</body>
</html>

Vlad GURDIGA

unread,
Jun 10, 2016, 4:02:21 AM6/10/16
to Mocha
Hi Ascani! 8-)

Ha! It seems like Mocha has a different set of methods for the TDD interface. Check what the docs say:

The TDD interface provides suite()test()suiteSetup()suiteTeardown()setup(), and teardown()
 
suite('Array', function() {
  setup
(function() {
   
// ...
 
});


  suite
('#indexOf()', function() {
    test
('should return -1 when not present', function() {
     
assert.equal(-1, [1,2,3].indexOf(4));
   
});
 
});
});

8-)

ascani...@gmail.com

unread,
Jun 10, 2016, 4:06:41 AM6/10/16
to Mocha


On Friday, June 10, 2016 at 4:02:21 PM UTC+8, Vlad GURDIGA wrote:
Hi Ascani! 8-)

Ha! It seems like Mocha has a different set of methods for the TDD interface. Check what the docs say:

Yes - thank you - that helps me understand the issue, TDD exports different globals

The yeoman scaffold (yo backbone) confused me because when you choose TDD it still uses describe in index.html. :-(

Vlad GURDIGA

unread,
Jun 10, 2016, 4:08:09 AM6/10/16
to Mocha
No problem! I’m glad it worked out! 8-)
Reply all
Reply to author
Forward
0 new messages