【发布时间】:2017-05-10 20:00:21
【问题描述】:
我正在从我的生产构建应用程序(nodeJS 应用程序)创建一个 docker 映像/容器用于测试目的。 现在我想使用 mocha/chai 和 nightmareJS 进行一些 e2e 测试。所以我创建了一个非常基本的测试文件。
我现在的问题是如何测试正在运行的应用程序。所以我想像“加载”应用程序
- goto http://localhost
- check if login form is existing
- do login
- check if login was successful
我不知道如何在我的 docker image / e2e.js-file 中执行此操作...
这就是我创建 docker 映像的方式:
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"]
这就是我的基本 e2e.js 文件的样子:
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
})
})
【问题讨论】:
标签: javascript node.js testing docker nightmare