Learn Protractor & Jasmine Framework for End to End Testing | Chapter 2 | Writing Test Suites

In order to start automating using Protractor, we need to understand two terms:

1. Spec file: It contains a describe(Test Suite), it block(tests). In one describe block we can have multiple it blocks.

describe("A suite is just a function"function() {
    var result;
  
    it("and so is a spec"function() {
        result = true;
  
      expect(a).toBe(true);
    });
  });

2. In order to execute the Spec file we need a configuration file which acts as a test runner similarly like testng.xml file in Selenium. It is the driver file with Spec details for test execution.


Let's create few tests using a dummy application:

Getting started with Tests:

1. Create an empty folder in D drive, name it as ProtractorAutomation
2. Open that folder in Visual Studio Code Editor
3. Create two files Spec.js and Configuration.js. Both are JavaScript files required to start working on protractor.


4. Go to Terminal and Install  Protractor locally for this project using Protractor to learn basics. Ideal approach is to use central package.json like we use POM.xml in Selenium as per standards but we are installing locally for learning purpose.

Commands:
> npm install protractor

Now paste below code in Spec.js and Configuration.js respectively

Spec.js


Configuration.js

Now GO to Terminal and execute your first Test Suite using Protractor and Jasmine.
Feel free to ask any questions on the same.




0 comments:

Post a Comment

Thanks a lot for your valuable Comment!