---
title: "Testing Angular apps using Protractor in JavaScript"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/74421521/Testing%20Angular%20apps%20using%20Protractor%20in%20JavaScript"
format: markdown
---
# Overview

In this tutorial, we will create some tests in JavaScript using Jasmine and Protractor.

# Requirements

- protractor
- jasmine
- jasmine-reporters

# Code


##### **conf.js**

```javascript
exports.config = {
  directConnect: true,
  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },
  // Framework to use. Jasmine is recommended.
  framework: 'jasmine',
  // Spec patterns are relative to the current working directory when
  // protractor is called.
  specs: ['example_spec.js'],
  // Options to be passed to Jasmine.
  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  },

  onPrepare: function() {
    var jasmineReporters = require('jasmine-reporters');
    var junitReporter = new jasmineReporters.JUnitXmlReporter({
      // setup the output path for the junit reports
      savePath: 'output/',
      // conslidate all true:
      //   output/junitresults.xml
      //
      // conslidate all set to false:
      //   output/junitresults-example1.xml
      //   output/junitresults-example2.xml
      consolidateAll: false
    });
    jasmine.getEnv().addReporter(junitReporter);
  }
};


```



##### **google_testing.js**

```javascript
describe('angularjs homepage', function() {
  it('should greet the named user', function() {
    browser.get('http://www.angularjs.org');
    element(by.model('yourName')).sendKeys('Julie');
    var greeting = element(by.binding('yourName'));
    expect(greeting.getText()).toEqual('Hello Julie!');
  });
  describe('todo list', function() {
    var todoList;
    beforeEach(function() {
      browser.get('http://www.angularjs.org');
      todoList = element.all(by.repeater('todo in todoList.todos'));
    });
    it('should list todos', function() {
      expect(todoList.count()).toEqual(2);
      expect(todoList.get(1).getText()).toEqual('build an angular app');
    });
    it('should add a todo', function() {
      var addTodo = element(by.model('todoList.todoText'));
      var addButton = element(by.css('[value="add"]'));
      addTodo.sendKeys('write a protractor test');
      addButton.click();
      expect(todoList.count()).toEqual(3);
      expect(todoList.get(2).getText()).toEqual('write a protractor test');
    });
  });
});
 
```


After running the tests and generating the JUnit XML report (e.g., ), it can be imported to Xray (by using either the REST API or the **Import Execution Results** action within the Test Execution).

```
 protractor  conf.js
```


JUnit's Test Case is mapped to a Generic Test in Jira, and the **Generic Test Definition** field contains the name of the test concatenated with the alias of each test case "assert" statement.

![image](media://21580d0a-7c44-4770-8ad4-5ceb798b30c3)


The Execution Details of the Generic Test contains information about the Test Suite, which in this case corresponds to the description of the first "describe".

![image](media://ae11a1a2-ed9b-4f9d-b072-6c07d57de658)

# References

- [http://www.protractortest.org/#/](http://www.protractortest.org/#/)
- [https://github.com/angular/protractor/blob/master/example/example_spec.js](https://github.com/angular/protractor/blob/master/example/example_spec.js)
- [https://github.com/angular/protractor/blob/master/docs/browser-setup.md](https://github.com/angular/protractor/blob/master/docs/browser-setup.md)
- [https://github.com/angular/protractor-cookbook/tree/master/jasmine-junit-reports](https://github.com/angular/protractor-cookbook/tree/master/jasmine-junit-reports)