GithubHelp home page GithubHelp logo

approvals-server's Introduction

approvals-server NPM version

A simple node HTTP server for running approval tests from the browser.

Install

If you use npm, then install the package via npm.

npm install approvals-server

If you're not using npm, simply copy the file index.js to a directory of your choice.

Server setup

var approvalsServer = require('approvals-server')();

Configuring the server

var approvalsServer = require('approvals-server')({
	approvals: {},		// See https://github.com/approvals/Approvals.NodeJS#config-override for all config options
	port: 1338,			// Default port
	path: './'			// Default path
});

If you need to you can manipulate the filenames by overriding the testNamer function like this:

var config = {
	testNamer: function (name) {
		return name.replace(/\W+/g, '-');
	}
}

Verify

To verify, do a POST to "http://localhost:1339/verify".

Parameters:

{
  "testName": "The name of the test",
  "data": "String to compare"
}

From the browser

The simplest thing possible is to do something like this.

function verify(test, data) {
	var xhr = new XMLHttpRequest();
	xhr.open('post', 'http://localhost:1339/verify', false);
	xhr.send(stringify({ testName: test, data: data }));
	return xhr.status === 200;
}

var data = {
	"Name": "Kristoffer",
	"Age": "Unknown"
};

verify('MyTest', JSON.stringify(data, null, 2));

Using curl

curl -H "Content-Type: application/json" -d '{ "testName": "Footest", "data": "Bar" }' http://localhost:1338/verify

More about Approvaltests

http://approvaltests.com

approvals-server's People

Contributors

cstead-hunter avatar dependabot[bot] avatar kristofferahl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

cmstead

approvals-server's Issues

Move to approvals 1.x

Hi,

Thanks for building this for the community!

Would it be reasonable to switch to approvals ^1.x at this point? I think the older configurations should continue to work with the newer version of approvals. If you'd like I can just send a pull request with the dependency update.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.