js-tests-results-collector
Version:
Universal test results collector for Jest, Jasmine, Mocha, Cypress, and Playwright that sends results to Buddy Works API
48 lines (40 loc) • 1.46 kB
JavaScript
const sessionManager = require('../../core/session-manager');
const TestResultMapper = require('../../utils/test-result-mapper');
const Logger = require('../../utils/logger');
class JasmineReporter {
constructor() {
this.logger = new Logger('JasmineReporter');
}
jasmineStarted(suiteInfo) {
this.logger.debug('Jasmine test run started', suiteInfo);
}
suiteStarted(result) {
this.logger.debug(`Suite started: ${result.description}`);
}
async specDone(result) {
try {
const mappedResult = TestResultMapper.mapJasmineResult(result);
await sessionManager.submitTestCase(mappedResult);
} catch (error) {
this.logger.error('Error processing Jasmine spec result', error);
// Mark this as a framework error since we failed to process test results
sessionManager.markFrameworkError();
}
}
suiteDone(result) {
this.logger.debug(`Suite done: ${result.description}`);
}
async jasmineDone(result) {
this.logger.debug('Jasmine test run completed', result);
try {
// Close the session when all tests are finished
await sessionManager.closeSession();
this.logger.debug('Session closed after Jasmine test completion');
} catch (error) {
this.logger.error('Error closing session after Jasmine test completion', error);
// Mark this as a framework error
sessionManager.markFrameworkError();
}
}
}
module.exports = JasmineReporter;