-
Notifications
You must be signed in to change notification settings - Fork 157
Tests just don't seem to run at all in grunt serve #219
Comments
@jtmkrueger edit your gruntfile and replace |
I create new yo backbone project with:
When I run
Tests are works when I run
|
did any fix this or found a solution to this. I am having the same issue workins on grunt test, but when i do grunt serve or grunt watch it fails with PhantomJS unable to load ..... |
figured out the issue had to run |
From this awesome post: http://puigcerber.wordpress.com/2013/12/23/using-grunt-to-run-mocha-tests-with-backbone-js-and-requirejs/ and some changes. Gruntfile.js mocha: {
all: {
options: {
run: true,
log: true,
reporter: 'Spec',
// reporter: 'Nyan', Nyan? Seriously ? Yeah! :)
// reporter: 'Progress',
timeout: 10000,
// src property used by default, which doesn't work
// src: ['http://localhost:<%= connect.test.options.port %>/index.html']
urls: ['http://localhost:<%= connect.test.options.port %>/index.html']
}
}
}, tests/index.html <body>
<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>
<div id="mocha"></div>
<script src="bower_components/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="bower_components/chai/chai.js"></script>
<script>
var assert = chai.assert;
var expect = chai.expect;
var should = chai.should();
</script>
<!-- include source files here... -->
<script src="scripts/main.js"></script>
<!-- you need this file for templates -->
<script src='scripts/templates.js'></script>
<!-- models, collections and views ORDER MATTERS -->
<script src="scripts/models/YOUR-MODEL.js"></script>
<!-- your test files -->
<script src="test/models/model.js"></script>
...
<!-- include spec files here... -->
<script src="spec/test.js"></script>
...
<script>
mocha.run();
</script>
</body>
</html> Run CLI:
Run browser
|
@lesterzone Thanks man, this worked for me, has anyone submitted a patch to fix the src/urls issue in the Gruntfile? |
I have submitted a fix a few MONTHS ago. |
I am still seeing this issue. 'grunt serve' initiates a watch task, which does its usual thing whenever I save a file. However, when it runs the mocha:all task, PhantomJS can't load the test runner file. Here's my output:
I'd love it to run my tests as part of 'watch', is this the intended behavior? |
I'm going to apologize beforehand, because I think I must be doing something obviously wrong, and I probably don't understand the underlying code enough to pinpoint it.
First off, Here's my Gruntfile.js. The only real modifications I've made are including sass.
Whenever I change a test file, I just see
fly by, even if I put obvious errors in the generated test files that should throw SyntaxErrors.
Is there something else I need to add to the gruntfile, or do I need to make changes to my
test/index.html
(here)?UPDATE
So until I get this figured out, I just started testing in the browser by loading up
test/index.html
. I updated the gist above to reflect where I'm at now, and this is working fine for me, but obviously I'd prefer to be using the cli interface.The text was updated successfully, but these errors were encountered: