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

parse-tester

v0.1.0

Published

Tool for creating parse based backend tests

Downloads

1

Readme

#Parse tester

Tool for creating automated tests for parse.com based based backends.

It's based on top of Jasmine, so you can group tests using describe and assert using expect.

To launch tests just launch node-jasmine <your-test-dir>. As in jasmine, only cases in files with their names ending with spec will be tested.

Getting started

To make TestCase constructing function avalilable you have to:

var TestCase = require('parse-tester')(config);

It's created this way for future tests because allow to override ALL of required dependencies. Config format is described below.

Config

Config is simple object as presented below:

var config = {
	apiUrl: 'https://api.parse.com/1/functions/',
	requestSetup: {
		hostname: 'api.parse.com',
		port: 443,
		method: 'POST',
		headers: {
			'X-Parse-Session-Token': '<your session token>',
			'X-Parse-Application-Id': '<yours application id>',
			'X-Parse-REST-API-Key': '<your rest api key>',
			'Content-Type': 'application/json'
		}
	}
};

Examples

The simplest test you can write is:

var noItems = new TestCase({
	title: 'simple test',
	types: [],
	data: [],
	request: {
		functionName: 'getItems',
		body: {}
	},
	assertions: function (response, data, types) {
		expect(true).toBe(true);
	}
});

Tester will create jasmine suite for given test and launch assertions after each needed request will be received. All given fields are required.

Given object has to be in format as given:

  • title - it's the same string which would you use in jasmine's describe
  • types - array with string containing names of types of which all objects will be downloaded from parse after making main request
  • data:
    • It can be array containing definitions of objects which will be persist in parse's database. Every object is in format as given:
      • type - name of object's type (it will be used for saving object in proper table)
      • body - object containing object's data
    • It can be object containing two fields:
      • items - array defined as above
      • links - array containing links (described below)
  • request - object containing two fields:
    • functionName - name of cloud code function which will called
    • body - object with request body (only data)
  • assertions - function containing all assertions for case. It will receive arguments: response, data, types where:
    • response - response object in format compatible with http/https node packages
    • data - object with data items, it's the same (but extended) object which was defined in data field, it is in format:
      • items - array containing defined items, every in format described below
      • links - array containing links
    • types - object containing downloaded whole tables as given in types field. Detailed description is below.

After that just call noItems.run().

Data items

  • type - type of given item
  • body - item's data
  • objectId - item's id (given by parse). This field is added in preparing data phase before request.
  • actual - actual item's state. This field is added in downloading data phase after request.

Links

It's way for creating connections between objects stored in parse's db.

  • source - index of object beeing a source of data for other object

  • func - linking function, it will receive object beeing source, can be used for example for preparing requests as given:

      var linkedRequest = new TestCase((function () {
      	var testObj = {
      		'title': 'linked request test',
      		types: [],
      		data: {
      			items: [
      				{
      					type: 'SomeType',
      					body: {
      						data: 'foo'
      					}
      				}
      			],
      			links: [
      				{
      					source: 0,
      					func: linker
      				}
      			]
      		},
      		request: {
      			functionName: 'someFunc',
      			body: null
      		},
      		assertions: function (response, data, types) {
      			expect(true).toBe(true);
      		}
      	};
      	function linker (item) {
      		testObj.request.body = {
      			id: item.objectId
      		};
      	}
      	return testObj;
      })());
  • target - index of linking target

  • properties - object containing properties to copy where key is property name in source object, value is string containing property name in target object. If source property is equal objectId, then will be created pointer to source object

If linking function is present, then target and properties are ignored.

Types

It's array containing names of types to download after main request. When data are downloaded, then under key beeing type name is array of objects with given type as they are stored in parse.