Created
October 16, 2012 18:12
-
-
Save lazd/3900997 to your computer and use it in GitHub Desktop.
grunt-mocha test failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global module:false*/ | |
module.exports = function(grunt) { | |
// External tasks | |
grunt.loadNpmTasks('grunt-mocha'); | |
grunt.initConfig({ | |
// Configure | |
mocha: { | |
cui: { | |
run: true, | |
src: [ | |
'index.html' | |
] | |
} | |
} | |
}); | |
// Default task | |
grunt.registerTask('default', 'mocha'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Mocha Tests</title> | |
<!-- Mocha CSS --> | |
<link rel="stylesheet" href="libs/mocha/mocha.css" /> | |
<!-- Chai --> | |
<script src="libs/chai/chai.js"></script> | |
<script> | |
var assert = chai.assert; | |
var expect = chai.expect; | |
</script> | |
<!-- Mocha --> | |
<script src="libs/mocha/mocha.js"></script> | |
<script>mocha.setup('bdd')</script> | |
</head> | |
<body> | |
<div id="mocha"></div> | |
<!-- Tests: Included in body --> | |
<script src="test.part1.js"></script> | |
<script src="test.part2.js"></script> | |
<!-- Do test run --> | |
<script> | |
(window.mochaPhantomJS || mocha).run(); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('window.location', function() { | |
// The following causes mocha-grunt to not catch failures in the next test script! | |
it('should be defined', function() { | |
expect(window).to.have.property('location'); | |
}); | |
describe('location', function() { | |
it('should have hash', function() { | |
expect(window.location).to.have.property('hash'); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('window.navigator', function() { | |
describe('user agent', function() { | |
it('should have james bond', function() { | |
expect(window.navigator).to.have.property('jamesBond'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need the following files for this to work:
Running the tests in the browser results in the
window.navigator.jamesBond
test to fail, running with grunt-mocha causes all tests to pass.