Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "it()" stand for in Jasmine?

Just curious what the function name it() stands for in the Jasmine Javascript test framework. Does it stand for something like "independent test" or something?

like image 592
Michael Malak Avatar asked Jan 07 '14 18:01

Michael Malak


People also ask

What is it function in Jasmine?

Jasmine is a testing framework for behavior driven development. And it function's purpose is to test a behavior of your code. It takes a string that explains expected behavior and a function that tests it.

What does it stand for in Jasmine?

What does Jasmine mean and stand for? The name Jasmine is of Persian origin and means "gift from God." It is derived from the Persian word yasmin, which is used for the flower. People used the scented oils from the flower to make perfume throughout the Persian Empire. Syllables: 2.

What is describe and it in Jasmine framework?

Jasmine is a testing framework for JavaScript. Suite is the basic building block of Jasmine framework. The collection of similar type test cases written for a specific file or function is known as one suite. It contains two other blocks, one is “Describe()” and another one is “It()”.

What is matchers in Jasmine?

Jasmine is a testing framework, hence it always aims to compare the result of the JavaScript file or function with the expected result. Matcher works similarly in Jasmine framework. Matchers are the JavaScript function that does a Boolean comparison between an actual output and an expected output.


2 Answers

It means "it", as in the word "it". As in the test declaration reads like a sentence. You describe an object by what it does. Simple as that.

For example:

Bowling ball is round

Bowling ball has 3 holes

Might translate to a test hierarchy like this:

Bowling Ball
  it is round
  it has three holes

Which would translate to the following testing setup:

describe(BowlingBall, function() {
  it('is round', function() {});
  it('has three holes', function() {});
});

So because it reads well, it just becomes the way you separate individual test cases. It also encourages you to write your test description in a consistent manner because it is part of the sentence that describes the test, which makes your test suite more readable over the long term.

In the end BDD is all about readability for the test writer. So this is simply sugar.

like image 90
Alex Wayne Avatar answered Oct 23 '22 05:10

Alex Wayne


Nothing like that. :)

It's a block to make more readable your specs. In particular, you can write stuff like this:

describe("When the user clicks the button", function() {
    it("renders the div with class .hello", function() {
        // your assertion here
    });
});

So you're test output in the console looks like:

When the user clicks the button renders the div with class .hello
like image 41
lucke84 Avatar answered Oct 23 '22 05:10

lucke84