Skip to content

Testing

Grant Carthew edited this page Mar 13, 2017 · 10 revisions

Description

There are over 1300 tests available to run against rethinkdb-job-queue. Due to the reliance on the RethinkDB database, they are integration tests rather than unit tests.

Prerequisites

Running the Tests

If you installed RethinkDB on your laptop and you are testing on your laptop you can simply do the following from a command line:

git clone https://github.com/grantcarthew/node-rethinkdb-job-queue
cd node-rethinkdb-job-queue
npm install
npm test

// or for verbose output

npm run tv

Note that some of the tests are time sensitive and I have seen the odd error in the tests if the order of events does not occur perfectly.

Customize Tests

If you do not have RethinkDB installed locally or you want to change the names of the database, please edit the test-options.js file to your liking. The top of the file looks like the following:

const dbHost = module.exports.dbHost = 'localhost'
const dbPort = module.exports.dbPort = 28015
const dbName = module.exports.dbName = 'rjqJobQueueTests'
const queueName = module.exports.queueName = 'rjqJobQueueTestJobs'

If you wish to run a tests for a single module use the example command below from within the rethinkdb-job-queue directory. This will make your testing a lot faster.

# Minimal output
> ./node_modules/.bin/tap ./tests/queue-process.spec.js

# Verbose output with extended test timeout
> ./node_modules/.bin/tap ./tests/queue-process.spec.js --timeout 10000 --reporter tap

If you make a mistake with the module name or run the command without a module argument the following help will be displayed:

 ==============================================
   INVALID TEST NAME!
   Use one of the test names below:
 ==============================================
   enums
   is
   datetime
   dbAssertDatabase
   dbAssertTable
   dbAssertIndex
   dbAssert
   dbDriver
   dbResult
   dbReview
   job
   jobOptions
   jobParse
   jobProgress
   jobCompleted
   jobUpdate
   jobFailed
   jobLog
   queue
   queueDb
   queueState
   queueAddJob
   queueGetJob
   queueFindJob
   queueGetNextJob
   queueReanimateJob
   queueProcess
   queueChange
   queueInterruption
   queueCancelJob
   queueRemoveJob
   queueReset
   queueStop
   queueDrop
   queueSummary
 ==============================================
   Example: npm run tc jobOptions
 ==============================================

Have you read the Debugging document yet?

Test Cleanup

The integration tests for rethinkdb-job-queue will leave an empty database on your RethinkDB server. Please connect to the RethinkDB web interface and delete the database.

Main

How It Works

Contributing

API

Queue Methods

Queue Properties

Queue Events

Job Methods

Job Properties

Documentation

Clone this wiki locally