Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/nightmare-tape
A wrapper for nightmare and tape for node.js full stack tests
https://github.com/binocarlos/nightmare-tape
Last synced: 10 days ago
JSON representation
A wrapper for nightmare and tape for node.js full stack tests
- Host: GitHub
- URL: https://github.com/binocarlos/nightmare-tape
- Owner: binocarlos
- License: mit
- Created: 2014-04-27T12:31:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-04-27T15:59:10.000Z (over 10 years ago)
- Last Synced: 2024-10-07T00:48:27.531Z (about 1 month ago)
- Language: JavaScript
- Size: 152 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
nightmare-tape
==============A wrapper for nightmare and tape for node.js full stack tests
## install
```
$ npm install nightmare-tape --save-dev
```## usage
Create tape tests as normal but inside a wrapper that provides a hooked up nightmare browser.
Pass a function which will create the server and another to close it down.
You MUST call tape.shutdown() as the last test otherwise phantom will hang.
```js
var http = require('http')
var concat = require('concat-stream')
var express = require('express')
var ecstatic = require('ecstatic')
var util = require('util')
var NightmareTape = require('../')var server = null
var app = nullvar serverState = {}
var browserState = {}function serverFactory(done){
app = express()
server = http.createServer(app)
app.use('/hello', function(req, res){
req.pipe(concat(function(body){
body = JSON.parse(body.toString())
serverState.username = body.username
res.end('world ' + body.username)
}))
})
app.use(ecstatic(__dirname + '/www'))
server.listen(8080, done)
}function closeServer(done){
server.close()
done && done()
}NightmareTape(serverFactory, closeServer, function(err, tape){
tape('trigger an ajax load to /hello', function(t){
tape.browser
.goto('http://127.0.0.1:8080')
.type('input#loginusername', 'rodney')
.click('button#login')
.wait(1000)
.evaluate('getReply', function(val){
browserState.reply = val
})
.run(function (err, nightmare) {
t.equal(serverState.username, 'rodney')
t.equal(browserState.reply, 'world rodney')
t.end()
});})
tape.shutdown()
})
```## license
MIT