UNPKG

cucumber-html-report-generator

Version:

Generate beautiful cucumberjs html reports for multiple instances (browsers / devices)

104 lines 4.83 kB
"use strict"; 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 path = __importStar(require("path")); const mocha_1 = require("mocha"); const feature_collector_1 = require("../../src/lib/feature-collector/feature-collector"); const chai_as_promised_1 = __importDefault(require("chai-as-promised")); const sinon_chai_1 = __importDefault(require("sinon-chai")); const { expect } = chai; chai.use(sinon_chai_1.default); chai.use(chai_as_promised_1.default); chai.use(sinon_chai_1.default); (0, mocha_1.describe)('CollectFeatures.ts', () => { (0, mocha_1.describe)('Happy flows', () => { (0, mocha_1.it)('should return an output from folder with features', async () => { // Given const reportGenerationProperties = { featuresFolder: path.resolve(process.cwd(), './test/unit/data/features/correct'), jsonDir: '' }; const collectFeatures = new feature_collector_1.CollectFeatureFiles(reportGenerationProperties); // When const collectedFeatures = await collectFeatures.collectFeatures(); // Then expect(collectedFeatures?.length).to.be.equal(3); }); }); (0, mocha_1.describe)('failures', () => { (0, mocha_1.it)('should not return an output if it does not find features', async () => { // Given const reportGenerationProperties = { featuresFolder: path.resolve(process.cwd(), './test/unit/data/cucumber-report-jsons'), jsonDir: '' }; const collectFeatures = new feature_collector_1.CollectFeatureFiles(reportGenerationProperties); // When const collectedFeatures = await collectFeatures.collectFeatures(); // Then expect(collectedFeatures).to.be.equal(null); }); (0, mocha_1.it)('should not return an output with a null folder', async () => { // Given const reportGenerationProperties = { jsonDir: '' }; const collectFeatures = new feature_collector_1.CollectFeatureFiles(reportGenerationProperties); // When await collectFeatures.collectFeatures().catch((error) => { // Then expect(error.message).equal("ENOENT: no such file or directory, stat 'null'"); }); }); (0, mocha_1.it)('should return a null with an undefined folder', async () => { // Given const reportGenerationProperties = { jsonDir: '', }; const collectFeatures = new feature_collector_1.CollectFeatureFiles(reportGenerationProperties); // When const result = await collectFeatures.collectFeatures(); // Then expect(result?.length).to.equal(0); }); (0, mocha_1.it)('should not return the features with the examples label written twice', async () => { // Given const reportGenerationProperties = { featuresFolder: path.resolve(process.cwd(), './test/unit/data/features//with failures/with-label-written-twice'), jsonDir: '' }; const collectFeatures = new feature_collector_1.CollectFeatureFiles(reportGenerationProperties); // When const collectedFeatures = await collectFeatures.collectFeatures(); // Then expect(collectedFeatures?.length).to.equal(1); }); }); }); //# sourceMappingURL=collect-features-spec.js.map