Nightwatch: How to configure nightwatch with expressjs app

Created on 1 Jun 2015  Â·  3Comments  Â·  Source: nightwatchjs/nightwatch

This is my server

// server/server.js
'use strict'

const express = require('express')
const config = require('./config')
const mongoose = require('mongoose')
// require('env-newrelic')()

mongoose.connect(config.db)

const app = express()
const server = require('http').createServer(app)
const socketio = require('socket.io')(server, {
  serveClient: (config.env === 'production') ? false : true,
  path: '/socket.io-client'
})

require('./config/socketio')(socketio)
require('./config/express')(app)
require('./routes')(app)

server.listen(config.port, function () {
  console.log(`Express app started on port ${config.port}`)
})

exports = module.exports = app

This is my test

// tests/test.js
'use strict'

require('../server/server.js')

module.exports = {
  'Server: Title Test' : function (client) {
    client
      .url('http://localhost:3000')
      .assert.title('amulen-core')
      .end()
  }
}

When I run the test does not complete the task, that is due to the callback but as I fix?

[Server] Test Suite
===================
Express app started on port 3000

Running:  Server: Title Test
 ✔ Testing if the page title equals "amulen-core".

OK. 1 assertions passed. (2.958s)

^C

Most helpful comment

+1 on @mmahalwy question

All 3 comments

Just by looking at your code samples I can't tell what's wrong. If you still have the problem maybe you can re-open and add more info on how to reproduce the issue.

@lgaticaq & @beatfactor is there a way to start express.js on nightwatch start? Say a beforeStart script or something like that.

+1 on @mmahalwy question

Was this page helpful?
0 / 5 - 0 ratings