@naxmefy/koa-starter
v1.0.1
Published
koa2 starter
Downloads
2
Readme
node-koa-starter
Installation
$ npm install --save @naxmefy/koa-starter
Usage
import Koa from 'koa'
import koaStarter from '@naxmefy/koa-starter'
const app = koaStarter(Koa, {})
if (!module.parent) {
app.start()
}
Usage (Testing - mocha + co-mocha + supertest)
import supertest from 'supertest'
import app from '../src'
before(function () {
this.app = koaStarter(Koa, {
onBootstrap () {
this.calledOnBooststrap = true
}
})
this.request = supertest(this.app.start({
port: null,
ip: null
}))
})
describe('app', function () {
it('should be bootstrapped', function () {
this.app.isBootstrapped.should.be.ok()
this.app.calledOnBooststrap.should.be.ok()
})
it('should response 404', function * () {
const response = yield this.request.get('/')
response.status.should.be.eql(404)
})
})