diff --git a/test/1_serverCypress.js b/test/1_serverCypress.js index 9017a3cc..fe779e7b 100644 --- a/test/1_serverCypress.js +++ b/test/1_serverCypress.js @@ -3,6 +3,23 @@ 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; + if (process.env.CYPRESS_RECORD_KEY && 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; @@ -23,23 +40,11 @@ describe('lot-occupancy-system', () => { assert.ok(serverStarted); }); describe('Cypress tests', () => { - it('should run Cypress tests', (done) => { - let cypressCommand = 'cypress run --config-file cypress.config.js --browser chrome'; - if (process.env.CYPRESS_RECORD_KEY && - 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(); - }); + 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); }); }); diff --git a/test/1_serverCypress.ts b/test/1_serverCypress.ts index 8f1c8398..1fea5965 100644 --- a/test/1_serverCypress.ts +++ b/test/1_serverCypress.ts @@ -9,6 +9,30 @@ import { exec } from 'node:child_process' import * as http from 'node:http' import { app } from '../app.js' +function runCypress(browser: 'chrome' | 'firefox', done: () => void) { + let cypressCommand = + 'cypress run --config-file cypress.config.js --browser ' + browser + + if (process.env.CYPRESS_RECORD_KEY && 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) @@ -35,31 +59,12 @@ describe('lot-occupancy-system', () => { }) describe('Cypress tests', () => { - it('should run Cypress tests', (done) => { - let cypressCommand = - 'cypress run --config-file cypress.config.js --browser chrome' + it('Should run Cypress tests in Chrome', (done) => { + runCypress('chrome', done) + }).timeout(30 * 60 * 60 * 1000) - if ( - process.env.CYPRESS_RECORD_KEY && - 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() - }) + it('Should run Cypress tests in Firefox', (done) => { + runCypress('firefox', done) }).timeout(30 * 60 * 60 * 1000) }) })