yachr
Version:
Yet another cucumber html reporter
232 lines • 8.45 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const featureSuiteSummary_1 = require("./models/aggregator/featureSuiteSummary");
const featureSummary_1 = require("./models/aggregator/featureSummary");
const scenarioSuiteSummary_1 = require("./models/aggregator/scenarioSuiteSummary");
const scenarioSummary_1 = require("./models/aggregator/scenarioSummary");
const suiteSummary_1 = require("./models/aggregator/suiteSummary");
const reportAggregator_1 = require("./reportAggregator");
const happyDayResult = require("./samples/results.json");
const skippedStep = require("./samples/skipped-step.json");
describe('report-aggregator', () => {
let aggregator;
let suite;
beforeEach(() => {
aggregator = new reportAggregator_1.ReportAggregator();
suite = { features: happyDayResult };
});
it('should aggregate a scenario', () => {
const summary = aggregator.getSummaryForScenario(suite.features[0].elements[0]);
const steps = [
{
arguments: [],
keyword: 'Given ',
line: 12,
name: 'Milton is not currently logged in',
result: {
duration: 1,
status: 'passed'
}
},
{
arguments: [],
keyword: 'When ',
line: 13,
name: 'Milton navigates to the login page',
result: {
duration: 1,
status: 'passed'
}
},
{
arguments: [],
keyword: 'Then ',
line: 14,
name: 'Milton should be directed to the AD Login',
result: {
duration: 1,
status: 'passed'
}
}
];
const expectedOutput = {
ambiguous: 0,
failed: 0,
passed: 3,
pending: 0,
scenarioDescription: '',
scenarioKeyword: 'Scenario',
scenarioName: 'Login via login page',
skipped: 0,
steps,
tags: '',
totalDuration: 5,
undefined: 0
};
// Had to do the JSON dance here to lose the _proto property
// from summary before doing the compare
(0, chai_1.expect)(JSON.parse(JSON.stringify(summary))).to.be.deep.equal(expectedOutput);
});
it('should aggregate a feature', () => {
const summary = aggregator.getSummaryForFeature(suite.features[0]);
const steps = [
{
arguments: [],
keyword: 'Given ',
line: 12,
name: 'Milton is not currently logged in',
result: {
duration: 1,
status: 'passed'
}
},
{
arguments: [],
keyword: 'When ',
line: 13,
name: 'Milton navigates to the login page',
result: {
duration: 1,
status: 'passed'
}
},
{
arguments: [],
keyword: 'Then ',
line: 14,
name: 'Milton should be directed to the AD Login',
result: {
duration: 1,
status: 'passed'
}
}
];
const scenarioSummary = Object.assign(Object.assign({}, new scenarioSummary_1.ScenarioSummary()), {
passed: 3,
scenarioKeyword: 'Scenario',
scenarioName: 'Login via login page',
steps,
totalDuration: 5,
});
const expectedOutput = Object.assign(Object.assign({}, new featureSummary_1.FeatureSummary()), {
featureDescription: 'Sample Feature Description',
featureKeyword: 'Ability',
featureName: 'Login',
passingScenarios: [scenarioSummary]
});
// Had to do the JSON dance here to loose the _proto property
// from summary before doing the compare
(0, chai_1.expect)(JSON.parse(JSON.stringify(summary))).to.be.deep
.equal(JSON.parse(JSON.stringify(expectedOutput)));
});
it('should aggregate a feature suite', () => {
const summary = aggregator.getSummaryForSuite(suite);
const steps = [
{
arguments: [],
keyword: 'Given ',
line: 12,
name: 'Milton is not currently logged in',
result: {
duration: 1,
status: 'passed'
}
},
{
arguments: [],
keyword: 'When ',
line: 13,
name: 'Milton navigates to the login page',
result: {
duration: 1,
status: 'passed'
}
},
{
arguments: [],
keyword: 'Then ',
line: 14,
name: 'Milton should be directed to the AD Login',
result: {
duration: 1,
status: 'passed'
}
}
];
const scenarioSummary = Object.assign(Object.assign({}, new scenarioSummary_1.ScenarioSummary()), {
passed: 3,
scenarioKeyword: 'Scenario',
scenarioName: 'Login via login page',
steps,
totalDuration: 5,
});
const featureSummary = Object.assign(Object.assign({}, new featureSummary_1.FeatureSummary()), {
featureDescription: 'Sample Feature Description',
featureKeyword: 'Ability',
featureName: 'Login',
passingScenarios: [scenarioSummary]
});
const expectedOutput = Object.assign(Object.assign({}, new suiteSummary_1.SuiteSummary()), {
featureSummary: Object.assign(Object.assign({}, new featureSuiteSummary_1.FeatureSuiteSummary()), {
passingFeatures: [featureSummary]
}),
scenarioSummary: Object.assign(Object.assign({}, new scenarioSuiteSummary_1.ScenarioSuiteSummary()), {
passingScenarios: [scenarioSummary]
})
});
// Had to do the JSON dance here to loose the _proto property
// from summary before doing the compare
(0, chai_1.expect)(JSON.parse(JSON.stringify(summary))).to.be.deep
.equal(JSON.parse(JSON.stringify(expectedOutput)));
});
it('should aggregate skipped steps', () => {
const skippedSuite = { features: skippedStep };
const summary = aggregator.getSummaryForScenario(skippedSuite.features[0].elements[0]);
const steps = [
{
arguments: [],
keyword: 'Given ',
line: 58,
match: {
location: 'e2e\\src\\steps\\search.steps.ts:87'
},
name: 'User has searched',
result: {
duration: 20,
status: 'pending'
}
},
{
arguments: [],
keyword: 'And ',
line: 59,
match: {
location: 'e2e\\src\\steps\\search.steps.ts:91'
},
name: 'multiple items have been returned',
result: {
duration: 10,
status: 'skipped'
}
}
];
const expectedSuiteSummary = {
ambiguous: 0,
failed: 0,
passed: 0, // This shouldn't be a pass, its a hidden step
pending: 1,
scenarioDescription: '',
scenarioKeyword: 'Scenario',
scenarioName: 'Login via login page',
skipped: 1,
steps,
tags: '',
totalDuration: 40,
undefined: 0,
};
(0, chai_1.expect)(JSON.parse(JSON.stringify(summary)))
.to.be.deep.equal(expectedSuiteSummary);
});
});
//# sourceMappingURL=reportAggregator.spec.js.map