Git Product home page Git Product logo

dynamodb-test's Introduction

dynamodb-test

Create and destroy DynamoDB and Dynalite tables for use in tape tests

Simple example

var tape = require('tape');
var tableDef = require('./table-definition.json');
var dynamodb = require('dynamodb-test')(tape, 'my-tests', tableDef, 'us-east-1');

dynamodb.test('my test', function(assert) {
  // starts your table, then runs your assertions, then purges your table
  assert.end();
});

// Clean up the table when you're done with it
dynamodb.delete();

API

var dynamodb = require('dynamodb-test')(tape, projectName, tableDef, [region], [port])

Configure the dynamodb object by providing your own tape object, an arbitrary name for your project, and the JSON object that defines the table's schema. Optionally, you may specify a region. If you do, tests will be run against a live DynamoDB table in that region. If you don't, tests will be run against a local instance of dynalite. If you specify a port, dynalite will listen on it, otherwise it will use 4567.

var dynamodb = require('dynamodb-test').fixedName(tape, tableName, tableDef)

To configure a dynalite test runner with a fixed table name.

dynamodb.dynamo

An instance of AWS.DynamoDB configured to query your test endpoint (live or dynalite).

dynamodb.dyno

A dyno instance configured to work against your test endpoint.

dynamodb.tableName

A randomly generated name of the table created for your tests.

dynamodb.tableDef

The table definition you provided, with TableName modified to match dynamodb.tableName

dynamodb.start()

Creates the table

dynamodb.delete()

Deletes the table.

dynamodb.load(fixtures)

By providing an array of dyno-style features, dynamodb-test can load them into your test database.

dynamodb.empty()

Empties all records from your table, for consistency across tests.

dynamodb.test(testName, [fixtures], callback)

A wrapper around tape that:

  • creates your table or empties it if it already exists
  • optionally, loads fixtures that you provide
  • runs your tests by providing an assertion object to your callback function
  • empties your table

dynamodb.close()

If you're working in a mock test environment, use this call to shut down dynalite.

dynamodb-test's People

Contributors

jseppi avatar rclark avatar

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.