Wednesday, 10 May 2017

NodeJS: How to do nightmareJS e2e-testing on running docker application

I am creating a docker image/container for testing purpose from my productive build application (nodeJS app). Now I want to do some e2e testing using mocha/chai and nightmareJS. So I have created a very basic test file.

My problem is now how to test for the running application. So I want to 'load' the application like

- goto http://localhost
- check if login form is existing
- do login
- check if login was successful

I don't know how to do this in my docker image / e2e.js-file...

This is how I'm creating the docker image:

Dockerfile

# Use the production image as base image
FROM productive_build:latest

# Copy the test files
COPY e2e.js /

# Override the NODE_ENV environment variable to 'dev', in order to get required test packages
ENV NODE_ENV dev

# 1. Get test packages; AND
# 2. Install our test framework - mocha
RUN (cd programs/server && npm install)
RUN npm install -g mocha
RUN npm install chai nightmare

# Override the command, to run the test instead of the application
CMD ["mocha", "e2e.js", "--reporter", "spec"]

And this is how my basic e2e.js file looks like:

e2e.js

var     Nightmare = require('nightmare'),
        expect = require('chai').expect

describe('test', function() {
    it('should always be true', function() {
        var nightmare = Nightmare()

        nightmare.end()
        expect(true).to.be.true
    })
})



via user3142695

No comments:

Post a Comment