Skip to content

Getting started writing tests for Etherpad Lite

John McLear edited this page Apr 6, 2020 · 12 revisions

We have partnered with SauceLabs to provide onDemand testing for Etherpad Lite.

To get started running and writing tests

Checkout the latest develop

git clone https://github.com/ether/etherpad-lite.git

cd etherpad-lite

git checkout feature/testing

bin/installDeps.sh

cp config.tmp.js config.js

Edit config.js

Add your saucelabs username/key (If you need one then please get in touch and we will provide you with one)

Running the tests

To run all of the tests across all browsers:

node runner.js

To run one tests across all browsers:

node runner.js --spec=makeTextBold.js

To run one test in one browser:

node runner.js --spec=makeTextBold.js --browser=firefox

To get help / instructions:

node runner.js --help

How to interact with the pad from inside a test.

We provide a sendkeys helper library for doing some operations but this is limited and sometimes you want to send keypresses using a jQuery trigger event.

An example of making the whole first line bold is this

    //get the first text element out of the inner iframe
    var $firstTextElement = inner$("div").first();

    //select this text element
    $firstTextElement.sendkeys('{selectall}');

    var e = inner$.Event("keydown"); // define the event
    e.ctrlKey = true; // Set the Control Key
    e.which = 66; // Set the keyCode of 66 which is Character "B"
    inner$("#innerdocbody").trigger(e); // trigger the event

Another way is to interact use the sendKeys library IE

    //get the first text element out of the inner iframe
    var $firstTextElement = inner$("div").first();

    //select this text element
    $firstTextElement.sendkeys('{selectall}');

    //replace the first line with hello world
    $firstTextElement.sendkeys('hello world');

Sendkeys can't do complex events such as Control Z but it is more readable for passing strings such as "Hello world"

Backend Tests

To run the backend tests

cd src then npm test

To run an individual test

npx mocha tests/backend/specs/api/chat.js

Or if you have mocha installed globally

mocha tests/backend/specs/api/chat.js

General

Resources

For Developers

How to's

Set up

Advanced steps

Integrating Etherpad in your web app

for Developers

Clone this wiki locally