ember.js - mocha testing doesn't work in the yeoman ember generator -
i've barely modify generated code ember generator
yo ember
and change test/spec/test.js little bit
'use strict'; (function () { describe('give context', function () { describe('maybe bit more context here', function () { it('should equal title', function () { var title = document.title; title.should.equal('ember starter kit'); console.log(title) //doesn't output in terminal }); it('should equal number', function () { 1.should.equal(1); }); }); }); })();
there's 2 strange thing:
- console.log doesn't output in terminal
it shows 0 test:
running "mocha:all" (mocha) task testing: http://..*.*/index.html
0 tests complete (1 ms)
done, without errors.
i've noticed when "0 tests complete", there's error within test file.
there 2 problems test:
- missing semicolon after console.log(title)
- executing method on integer syntax error. try following:
expect(1).to.equal(1);
also, sure include following lines in index.html
after chai inclusion (so should
works):
... <!-- assertion framework --> <script src="lib/chai.js"></script> <script>var expect = chai.expect</script> <script>var should = chai.should()</script> ...
this causes tests run. however, don't have answer console logging problem. i'm looking answer myself. seems grunt-mocha , phantomjs.
edit: turns out, console logging in grunt-mocha disabled: grunt-mocha source.
if go node_modules/grunt-mocha/tasks/mocha.js
within project directory, can uncomment line 101, , logging work project.
full updated test file:
/*global describe, it, document, expect */ 'use strict'; (function () { describe('give context', function () { describe('maybe bit more context here', function () { it('should equal title', function () { var title = document.title; title.should.equal('ember starter kit'); console.log(title); //doesn't output in terminal }); it('should equal number', function () { expect(1).to.equal(1); }); }); }); })();
edit: developer of grunt-mocha:
yup, uncomment line console output in command line... although don't want when running automated tests it's disabled default. if want debug, suggest opening spec in browser , using browser console/debugger. bonus can click on suite/test runs tests interested in.
Comments
Post a Comment