2

Jasmine テストを JavaScript から LiveScript に移植しようとしています。Jasmine の機能の 1 つにit. 次に例を示します。

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

だから、LiveScriptでこれを試しました:

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

これにコンパイルされます:

// 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(""));
});
});
})();

2 番目の関数が "it" を引数として取っていることがわかります。これに関するライブスクリプトのドキュメントは見つかりませんでしたが、それが機能であることは理解しています (it関数を別のものに置き換えても問題ありません。これにより、関数を部分的に適用していないことが確信できます)。

ただし、it関数が必要であり、引数として使用したくありません。では、このスニペットをどのように書くことができますか? ありがとう !

4

2 に答える 2

3

余分なパラメータを追加しないように、describe で (...) を使用する必要があります

そのように:

do !->
  describe "the selling page", (...) !->
   it "should display cards" !->
       expect (selectedCards.count()).toEqual("")
于 2015-10-16T18:29:16.147 に答える
1

it他の何かのエイリアシングを気にしない場合は、次のこともできます。

that = it

do !->
  describe "the selling page " !->
   that "should display cards" !->
       expect selectedCards.count! .to-equal ''

関数内にない場合itは global として扱われitます。

于 2016-10-27T17:38:33.113 に答える