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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rope

v1.0.1-pre

Published

test harness for minq queries

Readme

rope

test harness for minq queries

1.0.x of rope targets 1.0.x of minq

test all the things!

According to The complete mink harness video, the best kind of rope to use is nylon.

Stability

Experimental: Expect the unexpected. Please provide feedback on api and your use-case.

installation

$ npm install rope

example usage

a mocha-style test given:

foo.js:

var minq = require('minq')

module.exports = function () {
  return minq(process.env.DB).from('foos').toArray().then(function (foos) {
    // sure, we could have used a regex, but imagine more complicated application-level logic that you want to test against known database values
    return foos.filter(function (foo) { return foo.name.length > 3 })
  })
}

test-foo.js:

var rope = require('rope')
var moquire = require('moquire')
var chai = require('chai')
chai.should()

describe('foo', function () {
  it('returns names longer than 3 letters', function (done) {

    var spy = rope().stub({
       data: [
        {name: 'Al'},
        {name: 'Sue'},
        {name: 'Xerxes'}] 
      })
    var foo = moquire('foo', {minq: spy})

    foo().then(function (result) {
      result.should.deep.equal({name: 'Xerxes'})
    }).then(done, done)

  })
})

usage

rope() => MinqFakeBuilder

Constructor function. Returns a new MinqTestBuilder object.

MinqFakeBuilder#stub(config) => MinqFakeBuilder

Chainable. Set up return values for queries. config is an object with these properties:

  • data: (required) The return value. Depending on the expected cardinality of the query (eg, minq#one vs minq#toArray), this should be an Array or a scalar Object.
  • collection: The expected collection of the query.
  • where: The expected conditional clause of the query.

MinqFakeBuilder#minq() => MinqFake

Returns an object with the same interface as minq. Use this object in place of requiring minq in your functions under test.

Stub dispatch

When a single test is expecting multiple queries, you can distinguish return values by collection. For example, to test this:

function foo(userId) {
  return minq.from('users')
  .byId(userId)
  .select({country: 1})
  .one()
  .then(function (user) {
    return minq.from('countries')
      .byId(user.country)
      .one()
  })
}

you could do:

minq = rope()
  .stub({collection: 'users', data: {country: 12}})
  .stub({collection: 'countries', data: {name: 'Uganda'}})
  .minq()

foo('user2').then(function (val) {
  val.should.deep.equal({name: 'Uganda'})

  minq.queries[0].query.should.deep.equal({_id: 'user2'})
  minq.queries[1].query.should.deep.equal({_id: 'user2'})
})

Note that real minq#byId and minq#byIds coerce the values to BSON ObjectIds

This is likely to be refined in future versions.

Bonus knowledge

Minks are of the family Mustelidae, which also includes the weasels, otters and ferrets.

You may also be interested in how to put a harness on a tame mink

License

MIT. (c) 2013 jden [email protected]. See LICENSE.md