angularjs - What is the difference between describe() and it() in spec.js file in protractor? -


when writing test case in spec.js file in protractor 2 fields showing describe() , it(). use of them , when use?

// spec.js

describe('protractor demo app', function() {   it('should have title', function() {     ..   }); }); 

by reading come know answer.

sepc.js (how jasmine behavior-driven development framework testing javascript code works)

it has 2 main functions

suite describe your tests

a test suite begins call global jasmine function describe 2 parameters: string , function. string name or title spec suite - being tested. function block of code implements suite.

specs

specs defined calling global jasmine function it, which, describe takes string , function. string title of spec , function spec, or test. spec contains 1 or more expectations test state of code. expectation in jasmine assertion either true or false. spec true expectations passing spec. spec 1 or more false expectations failing spec.

describe("a suite", function() {   it("contains spec expectation", function() {      expect(true).tobe(true);   }); }); 

it's functions

since describe , it blocks functions, can contain executable code necessary implement test. javascript scoping rules apply, variables declared in describe available it block inside suite.

for more details can see this link


Comments