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

wallflower

v0.1.0

Published

Wallflower is a browser-driver test harness that is designed to run in the background of your host machine.

Downloads

13

Readme

Wallflower

Wallflower is a browser-driver test harness that is designed to run in the background of your host machine.

Goals

  1. No Focus
    • Should be able to run in the background on your local machine
  2. Simple API
    • Should be able to run with npm scripts
    • Should be able to integrate with other test runners (e.g., Mocha, Jest, etc.)

Usage

This package exports an abstraction layer over selenium-webdriver to simplify automation of certain websites (e.g., gmail). It also provides a CLI for running the tests in docker, to prevent the webdriver browser from requiring focus from your host machine.

Test Setup

You can use any test framework of your choosing, but the following example uses mocha

./tests/browser-extension.js

'use strict'

/* global describe, it */

const assert = require('assert')

const Browser = require('wallflower')

describe('Browser Extension Tests', function () {
  this.timeout(30000)

  let browser
  beforeEach(async function openBrowser () {
    // loading extension may take a while
    this.timeout(120000)
    browser = await Browser({ extensions: ['bp'] }) // looks at `./extensions/bp/${ENVIRONMENT_NAME}.crx`
  })

  afterEach(async function closeBrowser () {
    browser && await browser.quit()
    browser = undefined
  })

  describe('GMail Tests', function () {
    let gmail
    beforeEach(async function loginToGmail () {
      // loading extension may take a while; for some reason, this timeout overrides the outer beforeEach
      this.timeout(120000)
      gmail = await browser.gmail(require('./account'))
    })

    afterEach(async function logoutOfGmail () {
      gmail && await gmail.logout()
      gmail = undefined
    })

    it('should get a message id', async function () {
      const draft = await gmail.compose({ to: '[email protected]', subject: 'test', body: 'test' })

      const messageId = await draft.getMessageId()
      assert.ok(messageId.startsWith('#msg-a:'))

      await draft.discard()
    })
  })
})

Running Tests

There are three (3) ways you can run wallflower tests:

  1. npm test Running your tests just as you would normally is probably the simplest method, assuming you added the up() and down() calls in the before/after hooks. In this case, the test script will execute on your host machine and communicate with the automated browser running in a docker container.
  2. wallflower test In this case, along with the browser container, another docker container will be run to execute your test script.
  3. TARGET=local npm test This will run everything on your host machine, including the automated browser. In this case, the host machine should not be used and the browser should be allowed to keep focus throughout the duration of the test. This approach also requires that the webdriver executable be installed on your host machine. This approach is not recommended, as it defeats the entire purpose of building this package; however, it may be useful or necessary in some CI environments.

CLI

wallflower run

This is essentially an alias for npm run <script>, but will execute the command in a docker container as a sibling to the automated browser container.

wallflower test

Similar to npm test, this is an alias for wallflower run test.

wallflower debug

This is essentially an alias for wallflower run <script>, but will open enable debug inspection on port 9229.

wallflower up

This will start the browser container separately from your test script. This may be useful if you want to connect a VNC application for debugging purposes.

wallflower down

If you start the browser container separately, you must shut it down separately.

wallflower restart

Shortcut for wallflower down && wallflower up. Also aliased as wallflower reset.