mocha-casperjs: silent failures

I tried running the example in the docs but with an obvious error at the top:

// example.js
FOOBAR

describe('Google searching', function() {
  before(function() {
    casper.start('http://www.google.fr/')
  })

  it('should retrieve 10 or more results', function() {
    casper.then(function() {
      'Google'.should.matchTitle
      'form[action="/search"]'.should.be.inDOM.and.be.visible
      this.fill('form[action="/search"]', {
        q: 'casperjs'
      }, true)
    })

    casper.waitForUrl(/q=casperjs/, function() {
      (/casperjs/).should.matchTitle
    })
  })
})

and I ran it with:

$ mocha-casperjs example.js

  0 passing (1ms)

I would have expected an error to be raised like mocha does:

mocha example.js                                                                                                           

example.js:1
(function (exports, require, module, __filename, __dirname) { FOOBAR
                                                              ^

ReferenceError: FOOBAR is not defined
    at Object.<anonymous> (/Users/Choxi/Code/Bloc/mocha-casperjs/example.js:1:63)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at /usr/local/lib/node_modules/mocha/lib/mocha.js:220:27
    at Array.forEach (native)
    at Mocha.loadFiles (/usr/local/lib/node_modules/mocha/lib/mocha.js:217:14)
    at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:469:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:404:18)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:146:18)
    at node.js:404:3

Am I doing something wrong?

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 2
  • Comments: 16 (5 by maintainers)

Most upvoted comments

OK cool, I thought your previous comment meant it was unfixable, phew! 😃 Btw awesome work on this project, we’ve been using casper’s built-in tester module for our integration test suite, but it’s so janky compared to mocha/chai. This is exactly what we were looking for, and I’m excited to start migrating our tests over!