test(e2e): add end to end tests via cypress.io

This commit is contained in:
Benedikt Rötsch
2017-10-30 15:54:38 +01:00
committed by Benedikt Rötsch
parent 85ea880352
commit bd9e29b6eb
6 changed files with 309 additions and 1 deletions

33
test/e2e/run-e2e-test.js Normal file
View File

@@ -0,0 +1,33 @@
const http = require('http')
const { resolve } = require('path')
require('dotenv').config({ path: 'variables.env' })
const cypress = require('cypress')
const app = require('../../app')
const TEST_PORT = 3007
app.set('port', TEST_PORT)
const server = http.createServer(app)
const { CF_SPACE, CF_ACCESS_TOKEN, CF_PREVIEW_ACCESS_TOKEN } = process.env
server.on('error', console.error)
server.listen(TEST_PORT, function () {
cypress.run({
spec: resolve(__dirname, 'specs', 'the-example-app-spec.js'),
headed: !process.env.CI,
env: {
CF_SPACE, CF_ACCESS_TOKEN, CF_PREVIEW_ACCESS_TOKEN
}
})
.then(() => {
server.close()
process.exit(0)
}).catch(() => {
server.close()
process.exit(1)
})
})