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

bos-test

v0.1.3

Published

A collection of utilities to help test BlueOak Server projects

Downloads

3

Readme

BlueOak Logo

Build Status Coverage Status Dependency Status Dev Dependency Status

A BlueOak Server project to help simplify your tests.

Overview

bos-test (bot). Use bot to inject and configure your dependencies with a single call.

Installation

npm i -g bos-test

Configuration

Configure how bot should run in a bot.config.js file or create config objects in your tests.

module.exports = {
    includeByPath: [__dirname + '/services'],
    configs: [__dirname + '/config.one.json', __dirname + '/config.two.json'],
    logging: false
};

includeByPath Array - The path to any folder containing BlueOak services that are used in your tests

config Array - Paths to any configuration files that you'd like to overlay on top of BlueOak's default configuration. The configuration file at [n + 1] always has precedence over [n]. If a config object is created in code and explicitly passed into the inject call, it will be applied on top of any config defined in file.

logging Boolean - All logging via BlueOak's logger service is silenced by default in the output of tests. To enable logging as usual, set this value to true.

Note:

  • Only absolute paths are supported in bot config objects

Usage

my-service.js

var logger;

function init(_config_, _logger_) {
    logger = _logger_;      
    logger.info('I am a useless service');
}

function echo(msg) {
  return msg;
}

module.exports = {
    init: init,
    echo: echo
};

test-my-service.js

var bot = require('bos-test'),
    expect = bot.expect,
    botConfig = require('./bot.config');

 ...

bot.inject('my-service', botConfig).then(function (bos) {
    expect(bos.config).to.be.defined;
    expect(bos.logger).to.be.defined;
    expect(bos['my-service']).to.be.defined;

    expect(bos['my-service'].echo('hi')).to.equal('hi');

    done();
}).catch(done);

 ...

API

  • inject(serviceName [, botConfig [, overrideConfig]])

    Inject a service and all its dependencies

  • flush

    Flush globally loaded services

  • expose(pathToModule)

    Requires and rewires a module to access private properties

  • get(exposedModule, privateProperty

    Returns a private property within a given rewired module

  • set(exposedModule, privateProperty, value)

    Assign a value to a private property of an exposed module

Unaltered Chai interfaces

  • expect
  • should
  • assert

Unaltered Sinon interfaces

  • spy
  • stub
  • mock

Planned features

  • Optional and automatic spies for service methods
  • Optional and automatic stubbing of service methods
  • rewire services instead of require services for easy access to private properties