Is this an appropriate way to use Jasmine?


#1

Hello,

I’ve recently been back playing around with Velocity and was hoping to get some feedback on the appropriate usage of Jasmine. I’ve been using it somewhat like I would use rspec in rails (see example test below). I’m driving the UI with Jasmine and also directly accessing the database. Not sure if this is the way Jasmine is supposed to be used, as many of the examples I’ve looked at make use of spies etc. and don’t seem to interact with the DB.

Is Cucumber more appropriate for the type of testing I am doing? I’ve tried cucumber with both .NET and Rails applications in the past and have never really enjoyed it, I find something like rspec much easier to work with. Having said that if it’s the more appropriate way to go, maybe I need to bite the bullet and give it another try.

Thanks for any feedback!

Example test:

describe ("the todo page", function() {
    describe ("remove task", function() {
        beforeAll(function() {
            FactoryBoy.create('task');
        });
        afterAll(function() {
            FactoryBoy.destroyAll('task');
        })
        it ("should remove a task when the delete button is clicked", function() {
            // remove the task
            $('.delete').click();

            // ensure it is not in the database
            expect(Tasks.find().count()).toEqual(0);

            // ensure it is not in the UI
            expect($('li').size()).toEqual(0);
        });
    });
});

#2

Hi

The type of test you’re doing with Jasmine is also known as subcutaneous test. It has the advantage of speed and disadvantage of not truly testing the calls through the browser. Jasmine can be used in any way you like that works for you, and subcutaneous tests are a very valid way of testing.

Cucumber is a tool for doing executable specifications, which is the intersection between specification, documentation and automation. It’s much more than just e2e testing and is highly beneficial for collaboration and future proofing as you change or ramp up team members. If you would like these benefits, you should seriously consider executable specs.

Cucumber is currently the most supported framework for doing e2e testing as it uses Chimp, which we created to solve a lot of e2e pains. We want to add Jasmine into the mix so you can use Chimp directly from your Jasmine specs and get the same benefits, we just need a time machine to help us do it at Xolv.io!


#3

For anyone reading this thread that wants to help, we would welcome someone working with us to do the work in Chimp, or a company that needs this functionality to fund us to do the work, which in turn would go right back out to the community.


#4

Thanks for the detailed response Sam, gives me some things to think on. As well thanks for all the work you and others have put into Velocity!