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

dpd-test

v1.0.6

Published

easy peasy way to write deployd tests

Downloads

4

Readme

Easy way to write deployd tests without mongodb

Build Status

Usage

$ npm install dpd-test --save
$ NODE_PATH=node_modules node test/mytest.js

test/mytest.js:

var dpdTest = require('dpd-test')

dpdTest.run({
  port:3030, 
  before: function(dpd){}, 
  ready: function(dpd, done){
    console.log("ready to test")       // use your favorite testing framework here
    done()
  }, 
  done: function(err, database){
    console.log("done")                // inspect database content here  (or in file 'mongodb.test.js')
    process.exit( err ? 1 : 0 )
  }  
})

Voila, there you go

Options

| key | type | info | |-----------|--------------------|----------------------------------------------------------------------------------------------------| | ready | fn(dpd, done) | called when deployd server started. | | done | fn (err, database) | called when done() is called in ready(). You can inspect the contents of the database afterwards | | port | integer (3030) | port for the fake deployd server to listen on | | isRoot | boolean (false) | this sets req.isRoot = true on each request when dpd-ssh-key-header is sent (see auth example) | | patchFile | fn(file) | allows patching files during bootup | | noreset | boolean (false) | don't wipe database during startup (reuse db of previous test) |

Endpoint testing

var dpdTest = require('dpd-test')
var request = require('superagent')
var port = 3030

dpdTest.run({
  port: port, 
  ready: function(dpd, done){

    request
      .post('localhost:'+port+'/user/login')
      .set('Content-Type',  'application/json')
      .set('Accept',  'application/json')
      .send({ username: "foo", password:"foo" })
      .end(function(err,  res){
        done(res.body.status != 200) // return true when error
      })

  }, 
  done: function(err, database){
    process.exit( err ? 1 : 0 )
  }  
})

Authenticated test

Just specify a user, and the user is automatically created and authenticated:

	dpdTest.run({
		port: port, 
		patchFile: patchFiles, 
		user: {username:"foo", "password":"foo"}, 
		ready: function(dpd, done, sessionid ){

			request
				.get('localhost:'+port+'/user/me')
				.set('Cookie', 'sid='+sessionid)
				.set('Content-Type',  'application/json')
				.set('Accept',  'application/json')
				.end(function(err,  res){
					console.dir(res.body) // logged in
					done()
				})

		}, 
		done: function(err, database){
			console.log("done") 
			process.exit( err ? 1 : 0 )
		} 
	})

for testing roles check dpd-acl-roles-permissions

Patch files

Occasionally it can be handy to patch required files to mimic certain situations:

	var patchFiles = function(file){
		if( file.match(/resources\/foo\/config.json/) != null ){
			var mod = JSON.parse(require('fs').readFileSync(file))
			delete mod.user.properties
			return mod
		}
	}

	dpdTest.run({
		...
		patchFile: patchFiles
		...
	})