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

rethinkdb-mock

v0.7.1

Published

Spec-compliant unit-testing for RethinkDB queries

Downloads

1,045

Readme

rethinkdb-mock v0.7.1

Spec-compliant unit-testing for RethinkDB queries

The end goal is to replicate the API of rethinkdbdash. For all intents and purposes, you should get the same results. Please review the Feature support table before opening an issue.

Reusing and nesting queries are fully supported. :+1:

Check out the Releases tab for details about the newest versions.

 

Why use this?

  • Load JSON data into the database with db.load()
  • Or call db.init() to easily populate the database
  • Easily run specific tests (fit in Jasmine)
  • Avoid teardown between test suites
  • Avoid having to start a rethinkdb process before you can run tests
  • Avoid mutilating your development rethinkdb_data
  • Continuous integration compatibility

 

Getting started

  1. Install from Github:
npm install --save-dev rethinkdb-mock
  1. Put some boilerplate in your test environment:
const rethinkdb = require('rethinkdb-mock')

// Replace `rethinkdbdash` with `rethinkdb-mock`
const mock = require('mock-require')
mock('rethinkdbdash', rethinkdb)

// You must use the same database name as the code you're testing.
const db = rethinkdb({
  name: 'test' // The default value
})
  1. Use it in your test suites:
describe('Some test suite', () => {

  // Reset the database between suites.
  beforeAll(() => {
    db.init({
      users: [],
      friends: [],
    })

    // Optionally, load JSON into the database.
    db.load(__dirname, './data.json')
  })

  // Now create your tests...
})

 

Feature support

The entire Rethink API is not yet implemented. Get an idea of what's supported by referencing the table below.

Open an issue to request a feature be implemented. But try implementing it yourself if you have time! :+1:

If a method is not behaving as expected, please open an issue! But first check out TODO.md for a list of missing behaviors.

❌ means "not implemented yet"

⚠️ means "partially implemented"

💯 means "fully implemented"

% | Feature --- | --- ❌ | Changefeeds ❌ | Binary support ❌ | Date-time support ❌ | Geospatial support 💯 | r.table() 💯 | r.tableCreate() ❌ | r.tableList() 💯 | r.tableDrop() ❌ | r.indexCreate() ❌ | r.indexList() ❌ | r.indexDrop() ❌ | r.indexRename() ❌ | r.indexStatus() ❌ | r.indexWait() ⚠️ | r.row 💯 | r() or r.expr() 💯 | r.do() ❌ | r.args() 💯 | r.object() 💯 | r.branch() ⚠️ | r.typeOf() 💯 | r.uuid() ⚠️ | r.desc() ⚠️ | r.asc() ❌ | r.js() ❌ | r.json() ❌ | r.http() ❌ | r.error() ❌ | r.range() 💯 | table.get() 💯 | table.getAll() ⚠️ | table.insert() 💯 | table.delete() 💯 | query() or query.bracket() 💯 | query.nth() 💯 | query.getField() ⚠️ | query.hasFields() ❌ | query.withFields() ⚠️ | query.offsetsOf() ⚠️ | query.contains() ⚠️ | query.orderBy() 💯 | query.isEmpty() 💯 | query.count() 💯 | query.skip() 💯 | query.limit() 💯 | query.slice() ❌ | query.between() 💯 | query.merge() 💯 | query.pluck() ⚠️ | query.without() ⚠️ | query.replace() ⚠️ | query.update() ⚠️ | query.delete() 💯 | query.default() 💯 | query.and() 💯 | query.or() ⚠️ | query.eq() ⚠️ | query.ne() ⚠️ | query.gt() ⚠️ | query.lt() ⚠️ | query.ge() ⚠️ | query.le() ⚠️ | query.add() ⚠️ | query.sub() ⚠️ | query.mul() 💯 | query.div() ❌ | query.mod() ❌ | query.sum() ❌ | query.avg() ❌ | query.min() ❌ | query.max() ❌ | query.not() ❌ | query.ceil() ❌ | query.floor() ❌ | query.round() ❌ | query.random() ❌ | query.coerceTo() 💯 | query.map() ⚠️ | query.filter() ❌ | query.fold() ❌ | query.reduce() ❌ | query.forEach() ❌ | query.distinct() ❌ | query.concatMap() ❌ | query.innerJoin() ❌ | query.outerJoin() ❌ | query.eqJoin() ❌ | query.zip() ❌ | query.group() ❌ | query.ungroup() ❌ | query.sample() ❌ | query.setInsert() ❌ | query.setUnion() ❌ | query.setIntersection() ❌ | query.setDifference() ❌ | query.append() ❌ | query.prepend() ❌ | query.union() ❌ | query.difference() ❌ | query.insertAt() ❌ | query.spliceAt() ❌ | query.deleteAt() ❌ | query.changeAt() ❌ | query.keys() ❌ | query.values() ❌ | query.literal() ❌ | query.match() ❌ | query.split() ❌ | query.upcase() ❌ | query.downcase() ❌ | query.toJSON() or query.toJsonString() ❌ | query.info() ❌ | query.sync()

 

Contributing

Issues and pull requests are always appreciated! :grin:

If you have any questions, feel free to open an issue.

 

Getting started

# This tool compiles the `src` directory during `npm install`.
npm install -g coffee-build

git clone https://github.com/aleclarson/rethinkdb-mock
npm install

# Manually compile the `src` directory after you make any changes.
coffee -cb -o js src

 

Similar repositories