Files
OliveTin/integration-tests/runner.mjs
James Read 2ada67be04 Migrate integration-test infrastucture from Cypress to Selenium+Mocha (#170)
* cicd: Move cypress to selenium+mocha

* cicd: with is not supported unless using an a container

* cicd: relative path to mocha

* cicd: the integration-tests runner now starts/stops OliveTin

* cicd: Knowing the CWD helps debugging

* cicd: Headless chrome

* cicd: wait for integration-test server to be started

* fmt: Mostly fix isses from eslint

* cicd: #169 - Test multiple combo boxes

* fmt: let should be const

* cicd: Remove cypress entirely
2023-10-09 21:44:29 +00:00

62 lines
1.3 KiB
JavaScript

import process from 'node:process'
import waitOn from 'wait-on'
import { spawn } from 'node:child_process'
let ot = null
export default function getRunner () {
const type = process.env.OLIVETIN_TEST_RUNNER
console.log('OLIVETIN_TEST_RUNNER env value is: ', type)
switch (type) {
case 'local':
return new OliveTinTestRunnerLocalProcess()
case 'vm':
return null
case 'container':
return null
default:
return new OliveTinTestRunnerLocalProcess()
}
}
class OliveTinTestRunnerLocalProcess {
async start (cfg) {
ot = spawn('./../OliveTin', ['-configdir', 'configs/' + cfg + '/'])
const logStdout = process.env.OLIVETIN_TEST_RUNNER_LOG_STDOUT === '1'
if (logStdout) {
ot.stdout.on('data', (data) => {
console.log(`stdout: ${data}`)
})
ot.stderr.on('data', (data) => {
console.error(`stderr: ${data}`)
})
}
ot.on('close', (code) => {
if (code != null) {
console.log(`child process exited with code ${code}`)
}
})
/*
this.server = await startSomeServer({port: process.env.TEST_PORT});
console.log(`server running on port ${this.server.port}`);
*/
await waitOn({
'resources': ['http://localhost:1337/']
})
return ot
}
async stop () {
await ot.kill()
}
}