Open andyhmltn opened 11 years ago
I have access to a video that outlines ember.js debugging in the developer console very well (as well as some other tips), as for testing - mocha + chai is the best.
Awesome. Yeah I'm gunna look at different testing options. JavaScript doesn't seem to have the same solid options as something like python or ruby
you'd be surprised - it really does. Mocha is just a base with no assertions library - use something like Chai and you have both BDD and TDD. Jasmine's also pretty good for the browser side.
I played about with Jasmine yesterday. Seems a lot like rspec which is awesome.
Mocha + chai have the exact same syntax - but with Mocha you can write tests in coffeescript. i.e.
chai = require 'chai'
do chai.should
{User} = require '../user'
describe 'User', ->
user = null
it 'should have a name', ->
user = new User 'Declan'
user.name.should.equal 'Declan'
it 'should initially be unactivated', ->
user = new User 'Bob'
user.active.should.equal false
it 'should be able to be activated', ->
user = new User 'Jim'
user.activate().should.equal true
user.active.should.equal true
it 'should be able to set an email', ->
user = new User 'Declan'
user.setEmail('declandewet@me.com').should.equal 'declandewet@me.com'
user.email.should.equal 'declandewet@me.com'
it 'should be able to set a password', ->
user = new User 'Steve'
user.setPassword('pancakes').should.equal 'pancakes'
user.password.should.equal 'pancakes'
Then with this Cakefile you can run $ cake test
:
fs = require 'fs'
{exec} = require 'child_process'
task 'test', 'runs the tests', ->
exec 'clear && mocha --compilers coffee:coffee-script --reporter spec --colors', (err, stdout, stderr) ->
throw err if err
console.log stdout + stderr
Wow that's exactly what I needed! Thanks :)
I'm having quite a few problems getting tests to work with this application. Is there any chance you can add a small test that sees if the message is sent where you pressenter or something and then do a pull request of you've got time? Only a little one just to give me an idea of how they will work in production
I forgot to mention: could it be a browser based test? One that checks if an action is performed in the browser. That's the part I'm having trouble with
This really needs unit tests.