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

piri-piri

v0.4.0

Published

piri-piri is a browser orchestration to enable decentralized browser applications tests. Ah and it is hot :)

Downloads

8

Readme

piri-piri

piri-piri is a browser orchestration to enable decentralized browser applications tests. Ah and it is hot :)

Why does it exist

There are a panoply of excellent browser testing frameworks and services available today, however their focus is on testing browser implementations (CSS, HTML and JavaScript) and user interactions of the apps their are testing (clicks, mouse movements, what the user sees).

When it comes to testing to test a decentralized browser app or library, the focus stops being how a browser implements a specific behaviour, but how the decentralized network handles node joins and leaves and if nodes are effectively communicating between each other. In this scenario, we have several events that the server never sees or that the server never instructs the clients to do, so we need to create a new way to coordinate the browser joins and leaves and also how they interact between each other remotely and this is were piri-piri comes into play.

The specific set of problems piri-piri tries to solve:

  • browser times X, where 1<=X<=virtually unlimited - Most browser testing frameworks only let you launch a couple of browsers at a time, piri-piri aims to launch several browsers and/or tabs to load a webpage, in a local or distributed fashion.

  • instruct browsers on demand - Since there is a ton of stuff happening on browser decentralized apps, we can't just write a script to test and listen to events that happens in a single browser, there are triggers coming from all of them.

  • gather information and evaluate the state as a whole - collect the events and data generated by each browser and assess if the order was correct with pseudo external consistency

**why piri-piri? Well, to be honest, since I got to learn about SauceLabs in 2012 (during LXJS over some Nachos and Tabasco Hot Sauce), browser testing for me was always connected to spicy and sauce, so that inspired me to pick the one that is very famous on the portuguese cousine, that is, piri-piri :)

How to use it (API)

const pp = require('piri-piri')

Starting piri-piri

piri-piri needs to get initialized in order to create a WebSockets server which will be used as the bridge to transfer messages between your Node.js process where tests and assertions are being run and the browsers that get instantiated. To start it, do:

pp.start((err) => {
  done()
})

Launching an instance

In fact, what will get launched are headless electron processes.

pp.browser.spawn(<scriptPath>, <quantity>, (err) => {
  if (err) { }
  // ..
})

scriptPath is the path to the script that you want to run in the browser

How should your script to run on the browser look like

const ppc = require('../../src').client

module.exports = function (args) {
  ppc.connect((err, socket) => { // do this when you want to tell piri-piri that your app is ready
    if (err) {
      return console.log(err)
    }
    socket.on('exit', ppc.exit)
  })
}

Instruct a comamnd, a 'sum function' example

browser app

const ppc = require('../../src').client

module.exports = function (args) {
  ppc.handle('sum', (arr) => {
    var sum = Number(arr[0] + arr[1])
    ppc.send(sum)
  })

  ppc.connect((err) => {
    if (err) {
      return console.log(err)
    }
  })
}

tests side

pp.browser.spawn('./tests/scripts/method.js', 1, (err) => {
  if (err) { }
  var id = Object.keys(pp.clients)[0] // should be 0, electron is not being properly closed
  pp.browser.send(id, 'sum', 2, 2)
  setTimeout(() => {
    console.log(pp.clients[id].msgs[0]) // the 
    pp.browser.send(id, 'exit')
  }, 500)
})

Initial Development

The initial development for this project was supported by INESC-ID, during the development of David Dias' M.Sc