Code Monkey home page Code Monkey logo

syncano-testing-examples's Introduction

Syncano Testing Examples

Slack Status

End to End testing of React applications with Nightwatch

Introduction

In the mid of 2015 our front-end team took the challenge of rebuilding the entire Dashboard from scratch. In a matter of three months we built a new version using the React library. Since it was hard to keep up with writing unit tests at such demanding pace we decided that end-to-end (e2e) will be our go-to test strategy.

The most obvious choice for e2e tests is Selenium but there are many language bindings and frameworks to choose from. Eventually we settled on Nightwatch.js.

We wanted to share our experience, thus we have created this repository holding all our blog posts with code examples. Every part of it will be organized in a separate folder beginning with part- and number representing the blog posts number in the series.

Table of Contents

Part Title Folder
End to End testing of React apps with Nightwatch Part 1
Before(), after() hooks and custom commands in Nightwatch Part 2
Data Driven Testing at Syncano Part 3

Requirements

First thing you need to do is to install Node.js if you don’t yet have it. You can find the installation instructions on the Node.js project page. Once you have node installed, you can take advantage of it’s package manager called npm.

You will also need:

As they are all required for Selenium and Nightwatch to work properly.

Installation

Before you will be able to run any tests you should install proper part in it's folder. To do so just follow examples below, where X is post number/directory.

$ cd part-X/
$ npm install
$ npm run e2e-setup

Now you have installed all dependancies using npm and executed node script that installs selenium.

Contact

If you have any questions, or just want to say hi, drop us a line at [email protected].

syncano-testing-examples's People

Contributors

adamwardecki avatar gh3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

syncano-testing-examples's Issues

Need some help

I have used your project to create sample test framework but getting some issues

Sample Page Object code :

var artCommands = {
validateArts: function() {
this.api.elements('css selector','@ArtS', function(list){
})
})
};

module.exports = {
commands: [artCommands],
elements: {
arts: {
selector: 'div.index.section ul.index li'
}
}
};

In the above code when I used validateArts command in my test script its not able to get arts element using @ArtS in this.api.elements() method but if i pass css path it will works fine.

can you please help to resolve this issue why artCommands unable to retrieve elements using @ArtS.

And also I need help to retrieve all the child element of li element. can you please let me know how can I iterate list to get all the child elements of li tags and their value.

[commands] Test Suite Error

Hi,
I am following same steps mentioned in this repo but getting below error. Don't know why [default] Test Suite and [commands] Test Suite are kicking in. Can I configure something to stop this??

[Login Test] Test Suite
===========================

Running:  User Logs in
 ✔ Element <input[type=text]> was visible after 112 milliseconds.
 ✔ Element <button> was visible after 44 milliseconds.
 ✔ Expected element <div[name=welcome]> text to contain: "Welcome back" - condition was met in 264ms

OK. 3 assertions passed. (3.641s)

[default] Test Suite
========================

[commands] Test Suite
=========================

[commands :: 0] Test Suite
==============================

Running:  login
 ✖ TypeError: this.waitForElementVisible is not a function
    at Object.login (/Users/tapaskumarjena/Documents/Work/Lantern/ibid/dbs-ibanking-indo/e2e/pages/LoginPage.js:4:8)
    at _combinedTickCallback (internal/process/next_tick.js:95:7)

FAILED:  1 errors (4ms)

Unexpected Token Export

Hi,

I am getting following error when i am trying to run "npm test", am i doing something wrong.

Error Log
13:39:54.469 INFO - Launching a standalone Selenium Server
13:39:54.609 INFO - Java: Oracle Corporation 9.0.4+11
13:39:54.609 INFO - OS: Windows 10 10.0 amd64
13:39:54.626 INFO - v2.53.1, with Core v2.53.1. Built from revision a36b8b1
13:39:54.694 INFO - Driver class not found: com.opera.core.systems.OperaDriver
13:39:54.694 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
13:39:54.702 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN10
13:39:54.703 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
13:39:54.703 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
13:39:54.856 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4747/wd/hub
13:39:54.856 INFO - Selenium Server is up and running


Actual Error on Node Console
testLogin.js:1
(function (exports, require, module, __filename, __dirname) { export default [{
^^^^^^

SyntaxError: Unexpected token export
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at loader (.\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (.n\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)

Set environment variables on Windows (10)

Hi syncano,

I'm following your examples and I've seen the incorrect content at README.

Here yours

SET EMAIL="your_email"
SET PASSWORD="your_password"

However, if we have quote, the email value what filled in email textbox is "your_email" (expected your_email), and caused error when run Part 1 as below:
- User Logs in (26.999s) Expected element <//div[@class="description-field col-flex-1"]> to be visible - element was not found - expected "visible" but got: "not found" at Object.UserLogsIn [as User Logs in] (F:/personal-projects/syncano-testing-examples-master/part-1/tests/testLogin.js:11:26)

So, we should change to

SET EMAIL="your_email"
SET PASSWORD="your_password"

Tested and work correctly!

Thanks for your work ;)

Can't Find Jars

  1. You forgot to mention that nightwatch needs to be installed globally in order to run the nightwatch command.
  2. Running the nightwatch command results in "Error: Unable to access jarfile ./node_modules/selenium-standalone/.selenium/selenium-server/2.53.0-server.jar"

syncano-testing-examples_ -bash 80x24_and_end_to_end_testing_of_react_apps_with_nightwatch-_part_1

Error when run npm test

When i run test part-1, have a proplem. Error: Unable to access jarfile ./node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar. How to fix it. Help me!

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.