Skip to content

Instantly share code, notes, and snippets.

@Swizz

Swizz/index.js Secret

Created February 22, 2017 10:22
Show Gist options
  • Save Swizz/7cfca4779602e7f21d5134cead796945 to your computer and use it in GitHub Desktop.
Save Swizz/7cfca4779602e7f21d5134cead796945 to your computer and use it in GitHub Desktop.
fly-serve test poc
const path = require('path')
const test = require('ava')
const delay = require('delay')
const http = require('ava-http')
const Fly = require('fly')
test.beforeEach(function (t) {
const fly = new Fly({
plugins: [require('../')],
tasks: {
* serve(fly) {
yield fly.source(path.join(__dirname, '*')).serve({port: 3000})
}
}
})
t.context = {fly}
})
test(function * (t) {
yield t.context.fly.start('serve')
yield delay(500)
try {
const res = yield http.get('http://localhost:3000')
t.is(res, '<h1>It works!</h1>')
} catch (err) {
t.fail('server not started')
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment