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

@fpjs-incubator/broyster

v0.2.1

Published

Test tools

Downloads

6,849

Readme

Broyster Node.js tools

npm install --save-dev @fpjs-incubator/broyster
# or
yarn add --dev @fpjs-incubator/broyster
import * as broysterForBrowser from '@fpjs-incubator/broyster/browser'
import * as broysterForNode from '@fpjs-incubator/broyster/node'

// ...

Usage

This package exports the following:

  • @fpjs-incubator/broyster/node:
    • karmaPlugin That can be used for launching and reporting tests.
    • setHttpsAndServerForKarma That configures karma for HTTP and HTTPS testing without any additional work.
    • BrowserFlags Is a collection of currently supported browser arguments that are uniformed for convenience (for example: Incognito will add launching the browser in incognito mode for Chrome and Edge, but private mode for Firefox).
    • makeKarmaConfigurator Makes a function that applies an opinionated full configuration, used by Fingerprint's projects, to Karma.
  • @fpjs-incubator/broyster/browser:
    • retryFailedTests That allows overriding the different behavior of Jasmine specs. The new behavior will retry a failed test up until the maximum specified in the first parameter, with a delay between each such attempt, indicated by the second parameter (in miliseconds). Call this function in the root of any executable file, involved in your testing code, for example, in a Jasmine helper file. Once called, it affects all tests Jasmine runs, even in the other files. For Karma, you can add a file that contains the invocation and point it in your files, that way you will not have it tied to one specific test file.

Use node exports when using Node.js contexts, like configuring Karma. Use browser exports when using browser contexts, like Jasmine.

To use mixed HTTP/HTTPS testing, in your Karma config file you need to use:

import { setHttpsAndServerForKarma } from '@fpjs-incubator/broyster'

setHttpsAndServerForKarma(config)

Launchers

The launcher provides additional properties: useHttps to specify if this launcher is supposed to connect to the HTTPS server (true) or not.

useHttps: true

deviceType is used only on iOS and allows to choose from iPhone (default) and iPad. You don't need to set a specific device name, the launcher chooses a device automatically. Same on Android.

  Android11_ChromeLatest: {
    platform: 'iOS',
    deviceType: 'iPhone',
    osVersion: '17',
    browserName: 'Safari',
    useHttps: true,
  },

firefoxCapabilities an array of extra capabilities specifically for Firefox.

firefoxCapabilities: [
  ['key', 1],
  ['key2', true],
  ['key3', 'value'],
],

osVersion selects the given OS version and also it's beta counterpart. For example, setting the OS version to 17 will choose either 17 or 17 Beta.

Reporters

There is a dedicated reporter that will mark successful tests as passed in BrowserStack.

config.set({
  reporters: [...config.reporters, 'BrowserStack'],
})

BrowserStack specific settings

The following config options are available inside the browserStack section of the config:

  • idleTimeout: expressed in miliseconds, specifies the amount of time that BrowserStack is supposed to keep the session alive without any activity before automatically killing it.

Launcher specific settings

The following config options are available inside the browserStack section of the config:

  • queueTimeout: expressed in miliseconds, specifies the maximum amount of time to wait for a the BrowserStack queue to free up a slot.
  • flags: a unified set of extra arguments that will be passed to the browser. For example passing incognito will apply the relevant seting to the browsers for which the flags were specified (incongnito in Chrome, private mode in Firefox or nothing in the case of Safari). Currently supported flags can be found under the BrowserFlags export. Example:
  import { BrowserFlags } from '@fpjs-incubator/broyster/node'

  ...

  Incognito_Chrome: {
    platform: 'Windows',
    osVersion: '10',
    browserName: 'Chrome',
    browserVersion: '57',
    useHttps: true,
    flags: [BrowserFlags.Incognito],
  },

Full Karma configuration

makeKarmaConfigurator is an alternative to creating a Karma configuration from scratch. The function creates an opinionated configuration used by Fingerprint's projects, but has few options and easy to use. The configuration is aimed to run TypeScript tests with Jasmine.

Example:

  • karma.conf.ts
    import { makeKarmaConfigurator } from '@fpjs-incubator/broyster/node'
    
    module.exports = makeKarmaConfigurator({
        projectName: 'My project',
        includeFiles: ['src/**/*.ts'],
    })
  • Run tests in browsers on the current machine:
    karma start --preset local --single-run
  • Run tests in browsers, supported by Fingerprint, on BrowserStack:
    karma start --preset browserstack --single-run
    Or only beta versions of these browsers:
    karma start --preset browserstack-beta --single-run