meshblu-test-server
A helper for spinning up a meshblu-server for your tests
Last updated 3 years ago by octoblu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install meshblu-test-server 
SYNC missed versions from official npm registry.

meshblu-test-server

A helper for spinning up a meshblu-server for your tests

Example

const MeshbluServer = require('meshblu-test-server')
const MeshbluHttp = require('meshblu-http')

describe('your application', function() {
  before("start meshblu", function(done) {
    this.meshbluServer = new MeshbluServer()
    this.meshbluConfig = this.meshbluServer.getConfig()

    this.meshbluServer.start(done)
  })

  after("stop meshblu", function(done) {
    this.meshbluServer.destroy(done)
  })
  
  it('should be a valid meshblu server now', function(done) {
    const meshblu = new MeshbluHttp(this.meshbluConfig)
    meshblu.register({ type: 'test-device' }, (error, device) {
      if (error) return done(error)
      expect(device.uuid).to.exist
      done()
    })
  })
})

Sinon

If you use sinon.useFakeTimers, you need to whitelist the functions that are mocked out. This is because mongojs uses setTimeout a bunch under the hood and stopping time causes it to just never respond. Related docs: http://sinonjs.org/releases/v3.2.1/fake-timers/

const now = Date.now()
sinon.useFakeTimers({ now, toFake: ['Date'] })  // now is optional
moment().utc().format()  // moment should work as expected. AFAIK, moment only uses Date

Travis

In order for the server to work in travis, you'll need to add the following to your .travis.yml

services:
- redis
- mongodb

Current Tags

  • 1.2.5                                ...           latest (3 years ago)

16 Versions

  • 1.2.5                                ...           3 years ago
  • 1.2.4                                ...           3 years ago
  • 1.2.3                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (6)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |