Skip to content

Commit

Permalink
add tags to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Oct 9, 2024
1 parent 7838779 commit 3d9bd22
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 41 deletions.
43 changes: 25 additions & 18 deletions test/1_serverCypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ import { exec } from 'node:child_process';
import * as http from 'node:http';
import { app } from '../app.js';
import { portNumber } from './_globals.js';
const thirtyMinutesInMillis = 30 * 60 * 60 * 1000;
function runCypress(browser, done) {
let cypressCommand = `cypress run --config-file cypress.config.js --browser ${browser}`;
if ((process.env.CYPRESS_RECORD_KEY ?? '') !== '') {
cypressCommand += ` --tag "${browser},${process.version}" --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('lottery-licence-manager', () => {
const httpServer = http.createServer(app);
let serverStarted = false;
Expand All @@ -23,22 +41,11 @@ describe('lottery-licence-manager', () => {
assert.ok(serverStarted);
});
describe('Cypress tests', () => {
it('should run Cypress tests', (done) => {
let cypressCommand = 'cypress run --config-file cypress.config.ts --browser chrome';
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();
});
}).timeout(30 * 60 * 60 * 1000);
});
it('Should run Cypress tests in Chrome', (done) => {
runCypress('chrome', done);
}).timeout(thirtyMinutesInMillis);
it('Should run Cypress tests in Firefox', (done) => {
runCypress('firefox', done);
}).timeout(thirtyMinutesInMillis);
}).timeout(thirtyMinutesInMillis);
});
57 changes: 34 additions & 23 deletions test/1_serverCypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@ import { app } from '../app.js'

import { portNumber } from './_globals.js'

// eslint-disable-next-line @typescript-eslint/no-magic-numbers
const thirtyMinutesInMillis = 30 * 60 * 60 * 1000

function runCypress(browser: 'chrome' | 'firefox', done: () => void): void {
let cypressCommand = `cypress run --config-file cypress.config.js --browser ${browser}`

if ((process.env.CYPRESS_RECORD_KEY ?? '') !== '') {
cypressCommand += ` --tag "${browser},${process.version}" --record`
}

// eslint-disable-next-line security/detect-child-process, sonarjs/os-command
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('lottery-licence-manager', () => {
const httpServer = http.createServer(app)

Expand All @@ -34,28 +61,12 @@ describe('lottery-licence-manager', () => {
})

describe('Cypress tests', () => {
it('should run Cypress tests', (done) => {
let cypressCommand =
'cypress run --config-file cypress.config.ts --browser chrome'

if ((process.env.CYPRESS_RECORD_KEY ?? '') !== '') {
cypressCommand += ' --record'
}

const childProcess = exec(cypressCommand)
it('Should run Cypress tests in Chrome', (done) => {
runCypress('chrome', done)
}).timeout(thirtyMinutesInMillis)

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)
})
it('Should run Cypress tests in Firefox', (done) => {
runCypress('firefox', done)
}).timeout(thirtyMinutesInMillis)
}).timeout(thirtyMinutesInMillis)
})

0 comments on commit 3d9bd22

Please sign in to comment.