Jasmine (mocha) nested "it" tests

See this issue: https://github.com/visionmedia/mocha/issues/438

Seems that the intention is to force tests to be de-coupled. While inconvenient and possibly requiring more mocking, this behavior is useful because it requires less re-testing and provides a clearer image of exactly what is going wrong.

i.e. there are 2 tests, test A and test B, where B is dependent on A.

Test A breaks, B therefore breaking as well. You fix what is breaking test A, but may now be surprised to find that test B broke either in the process of your fix, or for an unrelated reason.

When the tests do not rely on each other, you have better information and fewer surprises.


I would have two tests for that. One that is testing insert and one that tests remove.

Should look something like this in coffeescript

describe 'Item model', () ->
   item = ''
   before (done) ->
      item = new Item {name: {first: "Alex"}}
      done
    describe 'When inserting Item', () ->
        before (done) ->
            item.save done
        it 'should have been insterted' ->
            #CHECK HERE IT IF IT IS INSERTED

    decribe 'when deleting', () ->
        before (done) ->
            item.save (err,data) ->
                return done err if err
                Item.delete {_id: data.id}, done
        it 'should have been deleted' ->
            #CHECK HERE IT IF IT IS Deleted