Debugging tips in Jasmine

We all know that Jasmine is a very popular unit testing framework for JavaScript, do we all know that there is something called 'Skipping' and 'Focusing' in Jasmine?

Skipping is basically to skip a particular or a set of test cases which is blocking the test suite or is unnecessary and can applied to both 'describe' and 'it' block, let's have an example with explanations as comments

xdescribe('Test Case - Describe', () => { // you can see that I have added an 'x' before describe which is basically to apply skipping in this block, it will skip all the test cases from execution

xit('Test Case - It',() => { // similar to the describe block, I'm adding 'x' in front of it to get this block skipped during the execution

expect(true).toBe(true);

})

})

Now let's come to the 'Focusing' part, it's kind of reverse to 'Skipping', what I mean to say is, we use it basically to focus on a particular or set of test cases and similar to 'Skipping' it can be applied to both 'describe' and 'it' block with a 'f' in front of it and it will execute only those set of tests in the whole test suite

You can refer the above example by replacing 'xdescribe' with 'fdescribe' and 'xit' with 'fit'

要查看或添加评论,请登录

Saikat Saha的更多文章

  • What's Spying on JS Testing?

    What's Spying on JS Testing?

    We all know that Jasmine is a unit-testing framework and it works only on logics but do you know whether it can spy on…

  • is 'Assertion' a confusing term?

    is 'Assertion' a confusing term?

    It's very obvious for many developers to be scared or confused about the term called 'assertion'. Most of us in the…

社区洞察

其他会员也浏览了