51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import * as assert from 'node:assert';
|
|
import { portNumber } from './_globals.js';
|
|
import { exec } from 'node:child_process';
|
|
import * as http from 'node:http';
|
|
import { app } from '../app.js';
|
|
function runCypress(browser, done) {
|
|
let cypressCommand = `cypress run --config-file cypress.config.js --browser ${browser} --tag "${browser},${process.version}"`;
|
|
if ((process.env.CYPRESS_RECORD_KEY ?? '') !== '') {
|
|
cypressCommand += ' --record';
|
|
}
|
|
const childProcess = exec(cypressCommand);
|
|
childProcess.stdout?.on('data', (data) => {
|
|
console.log(data);
|
|
});
|
|
childProcess.stderr?.on('data', (data) => {
|
|
console.error(data);
|
|
});
|
|
childProcess.on('exit', (code) => {
|
|
assert.ok(code === 0);
|
|
done();
|
|
});
|
|
}
|
|
describe('lot-occupancy-system', () => {
|
|
const httpServer = http.createServer(app);
|
|
let serverStarted = false;
|
|
before(() => {
|
|
httpServer.listen(portNumber);
|
|
httpServer.on('listening', () => {
|
|
serverStarted = true;
|
|
});
|
|
});
|
|
after(() => {
|
|
try {
|
|
httpServer.close();
|
|
}
|
|
catch {
|
|
}
|
|
});
|
|
it('Ensure server starts on port ' + portNumber.toString(), () => {
|
|
assert.ok(serverStarted);
|
|
});
|
|
describe('Cypress tests', () => {
|
|
it('Should run Cypress tests in Chrome', (done) => {
|
|
runCypress('chrome', done);
|
|
}).timeout(30 * 60 * 60 * 1000);
|
|
it('Should run Cypress tests in Firefox', (done) => {
|
|
runCypress('firefox', done);
|
|
}).timeout(30 * 60 * 60 * 1000);
|
|
});
|
|
});
|