test in both chrome and firefox
parent
6c8a13c346
commit
707c3113b5
|
|
@ -3,6 +3,23 @@ import { portNumber } from './_globals.js';
|
||||||
import { exec } from 'node:child_process';
|
import { exec } from 'node:child_process';
|
||||||
import * as http from 'node:http';
|
import * as http from 'node:http';
|
||||||
import { app } from '../app.js';
|
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', () => {
|
describe('lot-occupancy-system', () => {
|
||||||
const httpServer = http.createServer(app);
|
const httpServer = http.createServer(app);
|
||||||
let serverStarted = false;
|
let serverStarted = false;
|
||||||
|
|
@ -23,23 +40,11 @@ describe('lot-occupancy-system', () => {
|
||||||
assert.ok(serverStarted);
|
assert.ok(serverStarted);
|
||||||
});
|
});
|
||||||
describe('Cypress tests', () => {
|
describe('Cypress tests', () => {
|
||||||
it('should run Cypress tests', (done) => {
|
it('Should run Cypress tests in Chrome', (done) => {
|
||||||
let cypressCommand = 'cypress run --config-file cypress.config.js --browser chrome';
|
runCypress('chrome', done);
|
||||||
if (process.env.CYPRESS_RECORD_KEY &&
|
}).timeout(30 * 60 * 60 * 1000);
|
||||||
process.env.CYPRESS_RECORD_KEY !== '') {
|
it('Should run Cypress tests in Firefox', (done) => {
|
||||||
cypressCommand += ' --record';
|
runCypress('firefox', done);
|
||||||
}
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
}).timeout(30 * 60 * 60 * 1000);
|
}).timeout(30 * 60 * 60 * 1000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,30 @@ import { exec } from 'node:child_process'
|
||||||
import * as http from 'node:http'
|
import * as http from 'node:http'
|
||||||
import { app } from '../app.js'
|
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', () => {
|
describe('lot-occupancy-system', () => {
|
||||||
const httpServer = http.createServer(app)
|
const httpServer = http.createServer(app)
|
||||||
|
|
||||||
|
|
@ -35,31 +59,12 @@ describe('lot-occupancy-system', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Cypress tests', () => {
|
describe('Cypress tests', () => {
|
||||||
it('should run Cypress tests', (done) => {
|
it('Should run Cypress tests in Chrome', (done) => {
|
||||||
let cypressCommand =
|
runCypress('chrome', done)
|
||||||
'cypress run --config-file cypress.config.js --browser chrome'
|
}).timeout(30 * 60 * 60 * 1000)
|
||||||
|
|
||||||
if (
|
it('Should run Cypress tests in Firefox', (done) => {
|
||||||
process.env.CYPRESS_RECORD_KEY &&
|
runCypress('firefox', done)
|
||||||
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()
|
|
||||||
})
|
|
||||||
}).timeout(30 * 60 * 60 * 1000)
|
}).timeout(30 * 60 * 60 * 1000)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue