Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-tester

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-tester

Tool for creating parse based backend tests

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

#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.

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.

FAQs

Package last updated on 09 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc