test(e2e): add end to end tests via cypress.io
This commit is contained in:
committed by
Benedikt Rötsch
parent
85ea880352
commit
bd9e29b6eb
33
test/e2e/run-e2e-test.js
Normal file
33
test/e2e/run-e2e-test.js
Normal 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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user