npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wdio-client

v1.0.22

Published

The client part of the e2e testing framework

Downloads

48

Readme

webdriverio-client

This is a client for the webdriverio-server.

Setup

Setting up e2e tests for your app requires

  1. Prerequisites
  2. Setting up boilerplate
  3. Writing tests

Prerequisites

These instructions assume that you already have a server (either Mac or Ubuntu) running the webdriverio-server. The client will need :

Setting up boilerplate

We will describe a typical installation scenario with an ember project, but the client can easily be adapted for use with react projects (or any other setup).

In these instructions, we assume that the fully built application package is placed in the dist folder (default ember output directory) and the e2e tests are in the tests/e2e folder. If these are different for your application, just change these in the following instructions to point to the right place.

First, install webdriverio-client and also add it to the devDependencies.

npm install webdriverio-client --save-dev

Now, we will setup some command shortcuts for e2e testing. Edit package.json and add the following 2 command to the scripts section (create the scripts sections if its missing)...

  "scripts": {
    "e2e-test": "wdio-client remote_e2e_test serverip:3000 dist tests/e2e",
    "update-screenshots": "wdio-client update_screenshots"
  }

The first command e2e-test passes 4 arguments to the wdio-client script - remote_e2e_test, serverip:3000, dist and tests/e2e... the last 3 can be modified to suit your application. Here, serverip is the ip address of the server running the webdriverio-server process, which typically runs on port 3000. dist and tests/e2e are the application package folder and e2e tests folder, respectively.

We will now create the directory structure required for the e2e tests, screenshots and jasmine config file.

mkdir tests
mkdir tests/e2e
mkdir tests/e2e/screenshots

Create tests/e2e/jasmine.json and add the following...

{
    "spec_dir": "tests",
    "spec_files": [
        "e2e/**/*-spec.js"
    ]
}

Also, add the following to .gitignore...

test.tar.gz
tests/e2e/test-config.json
tests/e2e/screenshots/diff

Writing tests

Now, we are ready to create an e2e test. Create tests/e2e/main-spec.js and paste the following...

var webdriverio = require('webdriverio');
var webdrivercss = require('webdrivercss');
var testUtils = require('../../testUtils/utils').e2e
var testConfig = require('./test-config.json');

var url = testUtils.getUrl(testConfig);

var NORMAL_VIEWPORT_WIDTH = 1280;
var NORMAL_VIEWPORT_HEIGHT = 800;

describe('myapp e2e tests using ' + url, function () {
    var client, commonScreenshots;
    jasmine.DEFAULT_TIMEOUT_INTERVAL = 9999999;

    beforeEach(function () {
        commonScreenshots = {
            name: 'content',
            elem: 'html',
        };

        client = testUtils.init(webdriverio, webdrivercss, testConfig);

        client
            .setViewportSize({width: NORMAL_VIEWPORT_WIDTH, height: NORMAL_VIEWPORT_HEIGHT})
            .url(url);
    });

    afterEach(function (done) {
      client.end(done);
    });

    it('main-page renders appropriately', function (done) {
        client
            .pause(1000)
            .verifyScreenshots('main-page', [commonScreenshots], function () {
              client.call(done);
            });
    });

});

Since this test executes on the webdriverio-server, the dependencies only need to be installed on the server machine (they are, when using the webdriverio-server). So we don't need to worry about all the requires at the top.

Running the tests

To execute e2e tests...

npm run e2e-test

If tests fail because of a mismatch in screenshots, you can inspect the differences by checking out the images in tests/e2e/screenshots/diff.

If the new screenshots are accurate, you can update your reference screenshots by running

npm run update-screenshots