Search code examples
livescript

Jasmine tests in Livescript: "it" keyword conflict


I'm trying to port some Jasmine tests from javascript to LiveScript. One of Jasmine's functions is it. Here's an example:

(function(){
  describe("The selling page", function() {
    // bla bla
    it("should display cards.", function() {
        expect(selectedCards.count()).toEqual(1);
    });
});

So, I tried this in LiveScript:

do !->
  describe "the selling page " !->
   it "should display cards" !->
       expect (selectedCards.count()).toEqual("")

Which compiles to this:

// Generated by LiveScript 1.3.1
(function(){
   describe("the selling page ", function(it){ // <--- note the "it"
     it("should display cards", function(){
     expect(browser.getTitle().toEqual(""));
});
});
})();

You notice that the second function takes the "it" as an argument. I didn't find the livescript doc about this but I understand it's a feature (if I replace the it function by something else it's all fine. That makes me confident I'm not partially applying a function).

However, I need the it function and I don't want it as an argument. How can I write this snippet then ? Thanks !


Solution

  • You should use (...) in describe to avoid adding extra params

    Like that:

    do !->
      describe "the selling page", (...) !->
       it "should display cards" !->
           expect (selectedCards.count()).toEqual("")