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

node-tempdb

v1.4.0

Published

Piggy-backs off of PeanutButter.TempDb.Runner to provide a way for node tests to run against a temporary database

Downloads

21

Readme

node-tempdb

Test results on Linux Test results on Windows npm downloads per week

What is it?

A node package, piggy-backing off of the .net package PeanutButter.TempDb.Runner, to provide a mechanism for node tests to run against a temporary database.

Supported databases

  • mysql
  • localdb
  • sqlite

If you have requests for other engines, please file an issue at the PeanutButter GitHub repository. Engine support will only be considered if there is demand for it (one request is demand :grin:)

Usage

var db = new TempDb(Databases.mysql);
await db.start();

// configuration is available on db
const { host, user, password, database, port } = db.config;

// if you're using knex, there's a convenience wrapper for config:
const knex = Knex(db.knexConfig);

// now you have a clean, empty database!

// later
await db.stop();

TempDb provides a static method create as a shorthand for construction and starting:

var db = await TempDb.create(Databases.mysql);

TempDb should be perfectly usable from JavaScript:

let db = await TempDb.create("mysql");

// later
await db.stop();

Recommendations

  • MySql can take a few seconds to spin up. I suggest creating one TempDb in a beforeAll() and tearing it down in an afterAll()
  • you probably already have some kind of db-schema migration strategy in place. Point it at your new db and create a clean, useful database!

Troubleshooting MySql

Supported versions

PeanutButter.TempDb.Runner has been tested with the following versions of MySql:

  • 5.6 (Windows, OSX)
  • 5.7 (Windows)
  • 8.0.20 (Gentoo Linux)

Each of those versions has subtle differences which affect bootstrapping of the temporary instance. If you find that node-tempdb is unable to bootstrap mysql for any reason, please open an issue at GitHub. You should be prepared to help me debug it!

PeanutButter.TempDb.Runner will automagically find mysqld if:

  • it's in your path
  • you're on Windows and it's an installed service

Generally, this means:

  • an installed mysql server on Windows will just work
  • and installed mysql server on most Linux distros will just work
  • mysql installed via homebrew on OSX will work -- if you add the bin dir from the install folder to your PATH (as soon as I have an OSX machine to test on I'm sure I can automate this). brew info mysql should tell you where it's installed to. In the wild, I've seen the path /usr/local/mysql/bin as the home where mysqld might live on OSX.

Dev

If you want to work against this code, you should be able to:

  • clone
  • npm test

and

  1. the tests should all run
  2. you should have a local copy of the used version of PeanutButter.TempDb.Runner