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?
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 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.
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()”.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With