test in both chrome and firefox

deepsource-autofix-76c6eb20
Dan Gowans 2023-01-26 09:47:29 -05:00
parent 6c8a13c346
commit 707c3113b5
2 changed files with 51 additions and 41 deletions

View File

@ -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);
});
});

View File

@ -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)
})
})