Giter Site home page Giter Site logo

endtoendtestingsetup's Introduction

End to end testing setup for angular or javascript project

Why testing is needed?

As the application increasing day by day with new features, a developer also have to face the errors. It slow down the business in market place an led to decrease our customers. In this situation we would not any choise. We have to fix it anyhow. It takes lots of time and waste of money. Solution is o test our application in the development environment and on the live server.

To do so, here is the method which helps us to test our application automatically using protractor.

Yes, it takes time to learn for testing and setup in our project and it would be new thing for a new developer. But, somewere it helps us to make our application more reliable and saves time & money.

There are many ways to testing process like, beta testing black box testing, which you can learn from google or any other officeal sites. you can visite this like for instance

http://istqbexamcertification.com/why-is-testing-necessary/

Steps to setup end To End testing.

  1. open the command line in your project
  2. create the pakage.json using npm init and follow the steps
  3. run the command npm install protractor -g
  4. webdriver-manager update
  5. webdriver-manager start

explanation

  • After install protractor, it will install protractor and webdriver manager
  • The webdriver-manager is a helper tool. it get an instance of a Selenium Server running.
  • You have to update webdriver manage once it is first time
  • Once you start webdriver manage, It will start Selenium Server and output buncha og logs on cmd.
  • Protractor - test will send the send the resquest to the Selenium server an dgets control the local browser
  • You can easily see each and every status in http://localhost:4444/wd/hub.
  1. Now create and folder in your project directory (endTEnd)
  2. Inside the endToEnd folder, create conf.js and app.test.js files

Configuration

  1. Paste the folowing scripts in the conf.js file.
exports.config = {
    seleniumAddress: "http://localhost:4444/wd/hub",
    Capabilities: {
        'BoowserName': 'chrome'
    },
    specs: ['app.test.js'],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }
};

Test Scripts

  1. and in the app.tests.js file
describe('angularjs homepage todo list', function() {
  it('should add a todo', function() {
    browser.get('https://angularjs.org');

    element(by.model('todoList.todoText')).sendKeys('write first protractor test');
    element(by.css('[value="add"]')).click();

    var todoList = element.all(by.repeater('todo in todoList.todos'));
    expect(todoList.count()).toEqual(3);
    expect(todoList.get(2).getText()).toEqual('write first protractor test');

    // You wrote your first test, cross it off the list
    todoList.get(2).element(by.css('input')).click();
    var completedAmount = element.all(by.css('.done-true'));
    expect(completedAmount.count()).toEqual(2);
  });
});

The describe and it syntax is from the Jasmine framework. Please visite the link https://jasmine.github.io/2.0/introduction.html

Run the test

change directory (cd) to endToEnd folder. it is because the conf.js file is located there inside.

runn the following command

protractor conf.js

Using npm

Open the package.json in the scripts variable paste the folowing script

"test": "protractor ./endToEnd/cong.js"

Now your scripts willl like of the follwing

"scripts":{
    "test": "protractor ./endToEnd/cong.js"
}

Now, you can easily run the test using npm. npm test

...Good Luck...

endtoendtestingsetup's People

Contributors

devfacts avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.