Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use multiple expect in jasmine

I am using jasmine with jasmine-species . I am making a test of search in my site . In search there are multiple criteria a user can select . I want to know that how to expect with multiple criteria.

Suppose this is my case

expect(variable1).toEqual('');
expect(variable2).toEqual('');
expect(variable3).toEqual('');
expect(variable4).toEqual('');

My question is that i want to move all expects into single expect . Is this possible in jasmine ? if yes , then how ?

Thanks in advance

like image 722
Ancient Avatar asked Jul 04 '13 12:07

Ancient


People also ask

What is done () in Jasmine?

If the function passed to Jasmine takes an argument (traditionally called done ), Jasmine will pass a function to be invoked when asynchronous work has been completed.

What is beforeEach in Jasmine?

For initializing and cleaning your specs, Jasmine provides two global functions, beforeEach() and afterEach() : The beforeEach function is called once before each spec in the suite where it is called. The afterEach function is called once after each spec in the suite where it's called.

How do you write a loop in Jasmine test cases?

For example; describe('this is my looping test!' , function() { var input = [1,2,3]; var output = [10, 20, 30]; function test_my_times_ten(input, output) { it('should multiply ' + input + ' by 10 to give ' + output, function() { expect(input * 10). toEqual(output) }); } for(var x = 0; x < input.

How do you check forEach in Jasmine?

forEach(test => { expect(n / d). toEqual(q); }); }); }); This worked fine and will run all test cases. However, it runs all test cases in the one function and if a test case fails, Jasmine will not notify us exactly what exactly case failed.


1 Answers

expect(variable1 == 1 && variable2 == 2).toBeTruthy();

like image 74
aaa Avatar answered Sep 29 '22 07:09

aaa