cucumber-html-report-generator
Version:
Generate beautiful cucumberjs html reports for multiple instances (browsers / devices)
85 lines • 4.05 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai = __importStar(require("chai"));
const fse = __importStar(require("fs-extra"));
const path = __importStar(require("path"));
chai.should();
const collect_jsons_1 = require("../../src/lib/collect-jsons/collect-jsons");
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
chai.use(chai_as_promised_1.default);
const { expect } = chai;
describe('CollectJsons.ts', () => {
describe('Happy flows', () => {
it('should return an output from the merged found json files', async () => {
// Given
const outputReportPath = `${process.cwd()}/dist/test/reports/.tmp1/`;
if (await fse.pathExists(outputReportPath)) {
await fse.remove(outputReportPath);
}
await fse.mkdir(outputReportPath, { recursive: true });
const pathJsonsToBeJoined = path.resolve(process.cwd(), './test/unit/data/cucumber-report-jsons');
const resultsPath = path.resolve(process.cwd(), './test/unit/data/joined-cucumber-jsons/merged-output.json');
const userProperties = {
reportPath: outputReportPath,
jsonDir: pathJsonsToBeJoined,
saveCollectedJSON: true
};
const collectionJsons = new collect_jsons_1.CollectJsons(userProperties);
// When
const jsonRead = await collectionJsons.createJoinedJson();
// Then
const jsonExpected = await fse.readJson(resultsPath);
expect(jsonRead).to.be.deep.equal(jsonExpected);
});
});
describe('failures', () => {
it('should return no report from incorrect files', async () => {
const pathJsonsToBeJoined = path.resolve(process.cwd(), './test/unit/data/no-jsons');
const userProperties = {
reportPath: '',
jsonDir: pathJsonsToBeJoined
};
// When
await new collect_jsons_1.CollectJsons(userProperties).createJoinedJson().catch((error) => {
expect(error.message).equal(`No JSON files found in '${pathJsonsToBeJoined}'. NO REPORT CAN BE CREATED!`);
});
});
it('should throw an error when no json files could be found', async () => {
const pathJsonsToBeJoined = path.resolve(process.cwd(), './test/unit/data/no-jsons');
const userProperties = {
reportPath: '',
jsonDir: pathJsonsToBeJoined
};
await new collect_jsons_1.CollectJsons(userProperties).createJoinedJson().catch((error) => {
expect(error.message).equal(`No JSON files found in '${pathJsonsToBeJoined}'. NO REPORT CAN BE CREATED!`);
});
});
});
});
//# sourceMappingURL=collect-jsons-spec.js.map