Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cucumber/html-formatter

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cucumber/html-formatter - npm Package Compare versions

Comparing version 12.0.0 to 13.0.0

dist/src/cli-main.d.ts.map

4

.mocharc.json
{
"require": ["ts-node/register", "source-map-support/register"],
"require": ["tsconfig-paths/register", "ts-node/register", "source-map-support/register"],
"extension": ["ts", "tsx"],
"recursive": true,
"timeout": 10000
"timeout": 10000
}
const fs = require('fs')
const path = process.argv[2]
const html = fs.readFileSync(path, 'utf-8')
const puppeteer = require('puppeteer');
const puppeteer = require('puppeteer')
async function check() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] })
const page = await browser.newPage()
await page.setContent(html)

@@ -13,4 +13,4 @@ const dynamicHTML = await page.evaluate(() => {

return content && content.innerHTML
});
await browser.close();
})
await browser.close()

@@ -17,0 +17,0 @@ if(!dynamicHTML) throw new Error(`The file ${path} did not render a .cucumber-react element. Inspect manually.`)

@@ -15,3 +15,3 @@ /*

/*!
* Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
* Font Awesome Free 5.15.3 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)

@@ -96,17 +96,2 @@ */

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**

@@ -122,3 +107,3 @@ * elasticlunr - http://weixsong.github.io

/** @license React v0.20.1
/** @license React v0.20.2
* scheduler.production.min.js

@@ -141,3 +126,3 @@ *

/** @license React v17.0.1
/** @license React v17.0.2
* react-dom.production.min.js

@@ -151,3 +136,3 @@ *

/** @license React v17.0.1
/** @license React v17.0.2
* react.production.min.js

@@ -154,0 +139,0 @@ *

{
"name": "@cucumber/html-formatter",
"version": "12.0.0",
"version": "13.0.0",
"description": "HTML formatter for Cucumber",

@@ -17,44 +17,31 @@ "bin": {

"scripts": {
"nyc": "nyc --reporter=html --reporter=text mocha",
"test": "mocha",
"lint": "eslint --ext ts,tsx --max-warnings 0 src test",
"lint-fix": "eslint --ext ts,tsx --max-warnings 0 --fix src test",
"build": "tsc && webpack-cli && cp src/index.mustache.html dist/src && cp node_modules/@cucumber/react/dist/src/styles/cucumber-react.css dist"
"prepublishOnly": "tsc --build tsconfig.build.json"
},
"dependencies": {
"@cucumber/messages": "^14.0.1",
"commander": "^7.0.0"
"@cucumber/messages": "^15.0.0",
"commander": "^7.2.0",
"source-map-support": "^0.5.19"
},
"devDependencies": {
"@babel/core": "^7.12.13",
"@cucumber/gherkin-utils": "^3.0.0",
"@cucumber/query": "^8.0.0",
"@cucumber/react": "^12.0.0",
"@types/jsdom": "^16.2.6",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.25",
"@types/react": "^17.0.1",
"@types/react-dom": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"@babel/core": "^7.13.14",
"@cucumber/gherkin-utils": "^4.0.0",
"@cucumber/query": "^9.0.2",
"@cucumber/react": "^13.0.0",
"@cucumber/gherkin-streams": "^1.0.0",
"@cucumber/message-streams": "^1.0.0",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.37",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"babel-loader": "^8.2.2",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"mocha": "^8.2.1",
"npm-link-shared": "^0.5.6",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"puppeteer": "^7.0.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"source-map-support": "^0.5.19",
"ts-loader": "^8.0.15",
"mocha": "^8.3.2",
"puppeteer": "^8.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"ts-loader": "^8.1.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.3",
"webpack": "^5.21.2",
"webpack-cli": "^4.5.0"
"typescript": "^4.2.3",
"webpack": "^5.30.0",
"webpack-cli": "^4.6.0"
},

@@ -61,0 +48,0 @@ "bugs": {

export {};
//# sourceMappingURL=cli-main.d.ts.map

@@ -6,15 +6,15 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var messages_1 = require("@cucumber/messages");
var stream_1 = require("@cucumber/messages/dist/src/stream");
var commander_1 = __importDefault(require("commander"));
var package_json_1 = __importDefault(require("../package.json"));
var stream_2 = require("stream");
var CucumberHtmlStream_1 = __importDefault(require("./CucumberHtmlStream"));
const messages_1 = require("@cucumber/messages");
const message_streams_1 = require("@cucumber/message-streams");
const commander_1 = __importDefault(require("commander"));
const package_json_1 = __importDefault(require("../package.json"));
const stream_1 = require("stream");
const CucumberHtmlStream_1 = __importDefault(require("./CucumberHtmlStream"));
commander_1.default.version(package_json_1.default.version);
commander_1.default.option('-f, --format <format>', 'output format: ndjson|protobuf', 'protobuf');
commander_1.default.parse(process.argv);
var toMessageStream = commander_1.default.opts().format === 'ndjson'
? new stream_1.NdjsonToMessageStream(messages_1.messages.Envelope.fromObject.bind(messages_1.messages.Envelope))
: new stream_1.BinaryToMessageStream(messages_1.messages.Envelope.decodeDelimited.bind(messages_1.messages.Envelope));
stream_2.pipeline(process.stdin, toMessageStream, new CucumberHtmlStream_1.default(__dirname + '/../../dist/cucumber-react.css', __dirname + '/../../dist/main.js'), process.stdout, function (err) {
const toMessageStream = commander_1.default.opts().format === 'ndjson'
? new message_streams_1.NdjsonToMessageStream(messages_1.messages.Envelope.fromObject.bind(messages_1.messages.Envelope))
: new message_streams_1.BinaryToMessageStream(messages_1.messages.Envelope.decodeDelimited.bind(messages_1.messages.Envelope));
stream_1.pipeline(process.stdin, toMessageStream, new CucumberHtmlStream_1.default(__dirname + '/../../dist/cucumber-react.css', __dirname + '/../../dist/main.js'), process.stdout, (err) => {
if (err) {

@@ -21,0 +21,0 @@ // tslint:disable-next-line:no-console

@@ -5,2 +5,4 @@ /// <reference types="node" />

export default class CucumberHtmlStream extends Transform {
private readonly cssPath;
private readonly jsPath;
private template;

@@ -17,5 +19,3 @@ private preMessageWritten;

_flush(callback: TransformCallback): void;
private cssPath;
private writePreMessageUnlessAlreadyWritten;
private jsPath;
private writePostMessage;

@@ -27,1 +27,2 @@ private writeFile;

}
//# sourceMappingURL=CucumberHtmlStream.d.ts.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -19,6 +6,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = __importDefault(require("fs"));
var stream_1 = require("stream");
var CucumberHtmlStream = /** @class */ (function (_super) {
__extends(CucumberHtmlStream, _super);
const fs_1 = __importDefault(require("fs"));
const stream_1 = require("stream");
class CucumberHtmlStream extends stream_1.Transform {
/**

@@ -28,29 +14,26 @@ * @param cssPath

*/
function CucumberHtmlStream(cssPath, jsPath) {
var _this = _super.call(this, { objectMode: true }) || this;
_this.template = null;
_this.preMessageWritten = false;
_this.postMessageWritten = false;
_this.firstMessageWritten = false;
_this.cssPath = cssPath;
_this.jsPath = jsPath;
return _this;
constructor(cssPath, jsPath) {
super({ objectMode: true });
this.cssPath = cssPath;
this.jsPath = jsPath;
this.template = null;
this.preMessageWritten = false;
this.postMessageWritten = false;
this.firstMessageWritten = false;
}
CucumberHtmlStream.prototype._transform = function (envelope, encoding, callback) {
var _this = this;
_transform(envelope, encoding, callback) {
if (this.postMessageWritten) {
return callback(new Error('Stream closed'));
}
this.writePreMessageUnlessAlreadyWritten(function (err) {
this.writePreMessageUnlessAlreadyWritten((err) => {
if (err)
return callback(err);
_this.writeMessage(envelope);
this.writeMessage(envelope);
callback();
});
};
CucumberHtmlStream.prototype._flush = function (callback) {
}
_flush(callback) {
this.writePostMessage(callback);
};
CucumberHtmlStream.prototype.writePreMessageUnlessAlreadyWritten = function (callback) {
var _this = this;
}
writePreMessageUnlessAlreadyWritten(callback) {
if (this.preMessageWritten) {

@@ -60,9 +43,9 @@ return callback();

this.preMessageWritten = true;
this.writeTemplateBetween(null, '{{css}}', function (err) {
this.writeTemplateBetween(null, '{{css}}', (err) => {
if (err)
return callback(err);
_this.writeFile(_this.cssPath, function (err) {
this.writeFile(this.cssPath, (err) => {
if (err)
return callback(err);
_this.writeTemplateBetween('{{css}}', '{{messages}}', function (err) {
this.writeTemplateBetween('{{css}}', '{{messages}}', (err) => {
if (err)

@@ -75,50 +58,46 @@ return callback(err);

});
};
CucumberHtmlStream.prototype.writePostMessage = function (callback) {
var _this = this;
this.writePreMessageUnlessAlreadyWritten(function (err) {
}
writePostMessage(callback) {
this.writePreMessageUnlessAlreadyWritten((err) => {
if (err)
return callback(err);
_this.writeTemplateBetween('{{messages}}', '{{script}}', function (err) {
this.writeTemplateBetween('{{messages}}', '{{script}}', (err) => {
if (err)
return callback(err);
_this.writeFile(_this.jsPath, function (err) {
this.writeFile(this.jsPath, (err) => {
if (err)
return callback(err);
_this.writeTemplateBetween('{{script}}', null, callback);
this.writeTemplateBetween('{{script}}', null, callback);
});
});
});
};
CucumberHtmlStream.prototype.writeFile = function (path, callback) {
var _this = this;
var cssStream = fs_1.default.createReadStream(path, { encoding: 'utf-8' });
cssStream.on('data', function (chunk) { return _this.push(chunk); });
cssStream.on('error', function (err) { return callback(err); });
}
writeFile(path, callback) {
const cssStream = fs_1.default.createReadStream(path, { encoding: 'utf-8' });
cssStream.on('data', (chunk) => this.push(chunk));
cssStream.on('error', (err) => callback(err));
cssStream.on('end', callback);
};
CucumberHtmlStream.prototype.writeTemplateBetween = function (begin, end, callback) {
var _this = this;
this.readTemplate(function (err, template) {
}
writeTemplateBetween(begin, end, callback) {
this.readTemplate((err, template) => {
if (err)
return callback(err);
var beginIndex = begin == null ? 0 : template.indexOf(begin) + begin.length;
var endIndex = end == null ? template.length : template.indexOf(end);
_this.push(template.substring(beginIndex, endIndex));
const beginIndex = begin == null ? 0 : template.indexOf(begin) + begin.length;
const endIndex = end == null ? template.length : template.indexOf(end);
this.push(template.substring(beginIndex, endIndex));
callback();
});
};
CucumberHtmlStream.prototype.readTemplate = function (callback) {
var _this = this;
}
readTemplate(callback) {
if (this.template !== null) {
return callback(null, this.template);
}
fs_1.default.readFile(__dirname + '/index.mustache.html', { encoding: 'utf-8' }, function (err, template) {
fs_1.default.readFile(__dirname + '/index.mustache.html', { encoding: 'utf-8' }, (err, template) => {
if (err)
return callback(err);
_this.template = template;
this.template = template;
return callback(null, template);
});
};
CucumberHtmlStream.prototype.writeMessage = function (envelope) {
}
writeMessage(envelope) {
if (!this.firstMessageWritten) {

@@ -131,6 +110,5 @@ this.firstMessageWritten = true;

this.push(JSON.stringify(envelope.toJSON()));
};
return CucumberHtmlStream;
}(stream_1.Transform));
}
}
exports.default = CucumberHtmlStream;
//# sourceMappingURL=CucumberHtmlStream.js.map

@@ -7,1 +7,2 @@ import { messages } from '@cucumber/messages';

}
//# sourceMappingURL=main.d.ts.map
"use strict";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var e_1, _a;
Object.defineProperty(exports, "__esModule", { value: true });
var messages_1 = require("@cucumber/messages");
var react_1 = require("@cucumber/react");
var gherkin_utils_1 = require("@cucumber/gherkin-utils");
var query_1 = require("@cucumber/query");
var react_2 = __importDefault(require("react"));
var react_dom_1 = __importDefault(require("react-dom"));
var gherkinQuery = new gherkin_utils_1.Query();
var cucumberQuery = new query_1.Query();
var envelopesQuery = new react_1.EnvelopesQuery();
try {
for (var _b = __values(window.CUCUMBER_MESSAGES), _c = _b.next(); !_c.done; _c = _b.next()) {
var envelopeObject = _c.value;
var envelope = messages_1.messages.Envelope.fromObject(envelopeObject);
gherkinQuery.update(envelope);
cucumberQuery.update(envelope);
envelopesQuery.update(envelope);
}
const messages_1 = require("@cucumber/messages");
const react_1 = require("@cucumber/react");
const gherkin_utils_1 = require("@cucumber/gherkin-utils");
const query_1 = require("@cucumber/query");
const react_2 = __importDefault(require("react"));
const react_dom_1 = __importDefault(require("react-dom"));
const gherkinQuery = new gherkin_utils_1.Query();
const cucumberQuery = new query_1.Query();
const envelopesQuery = new react_1.EnvelopesQuery();
for (const envelopeObject of window.CUCUMBER_MESSAGES) {
const envelope = messages_1.messages.Envelope.fromObject(envelopeObject);
gherkinQuery.update(envelope);
cucumberQuery.update(envelope);
envelopesQuery.update(envelope);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
var app = (react_2.default.createElement(react_1.QueriesWrapper, { gherkinQuery: gherkinQuery, cucumberQuery: cucumberQuery, envelopesQuery: envelopesQuery },
const app = (react_2.default.createElement(react_1.QueriesWrapper, { gherkinQuery: gherkinQuery, cucumberQuery: cucumberQuery, envelopesQuery: envelopesQuery },
react_2.default.createElement(react_1.FilteredResults, null)));
react_dom_1.default.render(app, document.getElementById('content'));
//# sourceMappingURL=main.js.map
export {};
//# sourceMappingURL=CucumberHtmlStreamTest.d.ts.map

@@ -11,40 +11,2 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -54,93 +16,50 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var messages_1 = require("@cucumber/messages");
var CucumberHtmlStream_1 = __importDefault(require("../src/CucumberHtmlStream"));
var stream_1 = require("stream");
var assert_1 = __importDefault(require("assert"));
function renderAsHtml() {
var envelopes = [];
for (var _i = 0; _i < arguments.length; _i++) {
envelopes[_i] = arguments[_i];
}
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var e_1, _a;
var html = '';
var sink = new stream_1.Writable({
write: function (chunk, encoding, callback) {
html += chunk;
callback();
},
});
sink.on('finish', function () { return resolve(html); });
var cucumberHtmlStream = new CucumberHtmlStream_1.default(__dirname +
'/../node_modules/@cucumber/react/dist/src/styles/cucumber-react.css', __dirname + '/../dist/main.js');
cucumberHtmlStream.pipe(sink);
try {
for (var envelopes_1 = __values(envelopes), envelopes_1_1 = envelopes_1.next(); !envelopes_1_1.done; envelopes_1_1 = envelopes_1.next()) {
var envelope = envelopes_1_1.value;
cucumberHtmlStream.write(envelope);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (envelopes_1_1 && !envelopes_1_1.done && (_a = envelopes_1.return)) _a.call(envelopes_1);
}
finally { if (e_1) throw e_1.error; }
}
cucumberHtmlStream.end();
})];
const messages_1 = require("@cucumber/messages");
const CucumberHtmlStream_1 = __importDefault(require("../src/CucumberHtmlStream"));
const stream_1 = require("stream");
const assert_1 = __importDefault(require("assert"));
function renderAsHtml(...envelopes) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
let html = '';
const sink = new stream_1.Writable({
write(chunk, encoding, callback) {
html += chunk;
callback();
},
});
sink.on('finish', () => resolve(html));
const cucumberHtmlStream = new CucumberHtmlStream_1.default(`${__dirname}/dummy.css`, `${__dirname}/dummy.js`);
cucumberHtmlStream.on('error', reject);
cucumberHtmlStream.pipe(sink);
for (const envelope of envelopes) {
cucumberHtmlStream.write(envelope);
}
cucumberHtmlStream.end();
});
});
}
describe('CucumberHtmlStream', function () {
it('writes zero messages to html', function () { return __awaiter(void 0, void 0, void 0, function () {
var html;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, renderAsHtml()];
case 1:
html = _a.sent();
assert_1.default(html.indexOf('window.CUCUMBER_MESSAGES = []') >= 0);
return [2 /*return*/];
}
describe('CucumberHtmlStream', () => {
it('writes zero messages to html', () => __awaiter(void 0, void 0, void 0, function* () {
const html = yield renderAsHtml();
assert_1.default(html.indexOf('window.CUCUMBER_MESSAGES = []') >= 0);
}));
it('writes one message to html', () => __awaiter(void 0, void 0, void 0, function* () {
const e1 = messages_1.messages.Envelope.create({
testRunStarted: messages_1.messages.TestRunStarted.create({}),
});
}); });
it('writes one message to html', function () { return __awaiter(void 0, void 0, void 0, function () {
var e1, html;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
e1 = messages_1.messages.Envelope.create({
testRunStarted: messages_1.messages.TestRunStarted.create({}),
});
return [4 /*yield*/, renderAsHtml(e1)];
case 1:
html = _a.sent();
assert_1.default(html.indexOf("window.CUCUMBER_MESSAGES = [" + JSON.stringify(e1.toJSON()) + "]") >= 0);
return [2 /*return*/];
}
const html = yield renderAsHtml(e1);
assert_1.default(html.indexOf(`window.CUCUMBER_MESSAGES = [${JSON.stringify(e1.toJSON())}]`) >= 0);
}));
it('writes two messages to html', () => __awaiter(void 0, void 0, void 0, function* () {
const e1 = messages_1.messages.Envelope.create({
testRunStarted: messages_1.messages.TestRunStarted.create({}),
});
}); });
it('writes one message to html', function () { return __awaiter(void 0, void 0, void 0, function () {
var e1, e2, html;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
e1 = messages_1.messages.Envelope.create({
testRunStarted: messages_1.messages.TestRunStarted.create({}),
});
e2 = messages_1.messages.Envelope.create({
testRunFinished: messages_1.messages.TestRunFinished.create({}),
});
return [4 /*yield*/, renderAsHtml(e1, e2)];
case 1:
html = _a.sent();
assert_1.default(html.indexOf("window.CUCUMBER_MESSAGES = [" + JSON.stringify(e1.toJSON()) + "," + JSON.stringify(e2.toJSON()) + "]") >= 0);
return [2 /*return*/];
}
const e2 = messages_1.messages.Envelope.create({
testRunFinished: messages_1.messages.TestRunFinished.create({}),
});
}); });
const html = yield renderAsHtml(e1, e2);
assert_1.default(html.indexOf(`window.CUCUMBER_MESSAGES = [${JSON.stringify(e1.toJSON())},${JSON.stringify(e2.toJSON())}]`) >= 0);
}));
});
//# sourceMappingURL=CucumberHtmlStreamTest.js.map
{
"name": "@cucumber/html-formatter",
"version": "12.0.0",
"version": "13.0.0",
"description": "HTML formatter for Cucumber",

@@ -17,44 +17,31 @@ "bin": {

"scripts": {
"nyc": "nyc --reporter=html --reporter=text mocha",
"test": "mocha",
"lint": "eslint --ext ts,tsx --max-warnings 0 src test",
"lint-fix": "eslint --ext ts,tsx --max-warnings 0 --fix src test",
"build": "tsc && webpack-cli && cp src/index.mustache.html dist/src && cp node_modules/@cucumber/react/dist/src/styles/cucumber-react.css dist"
"prepublishOnly": "tsc --build tsconfig.build.json"
},
"dependencies": {
"@cucumber/messages": "^14.0.1",
"commander": "^7.0.0"
"@cucumber/messages": "^15.0.0",
"commander": "^7.2.0",
"source-map-support": "^0.5.19"
},
"devDependencies": {
"@babel/core": "^7.12.13",
"@cucumber/gherkin-utils": "^3.0.0",
"@cucumber/query": "^8.0.0",
"@cucumber/react": "^12.0.0",
"@types/jsdom": "^16.2.6",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.25",
"@types/react": "^17.0.1",
"@types/react-dom": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"@babel/core": "^7.13.14",
"@cucumber/gherkin-utils": "^4.0.0",
"@cucumber/query": "^9.0.2",
"@cucumber/react": "^13.0.0",
"@cucumber/gherkin-streams": "^1.0.0",
"@cucumber/message-streams": "^1.0.0",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.37",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"babel-loader": "^8.2.2",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"mocha": "^8.2.1",
"npm-link-shared": "^0.5.6",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"puppeteer": "^7.0.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"source-map-support": "^0.5.19",
"ts-loader": "^8.0.15",
"mocha": "^8.3.2",
"puppeteer": "^8.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"ts-loader": "^8.1.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.3",
"webpack": "^5.21.2",
"webpack-cli": "^4.5.0"
"typescript": "^4.2.3",
"webpack": "^5.30.0",
"webpack-cli": "^4.6.0"
},

@@ -61,0 +48,0 @@ "bugs": {

import { messages } from '@cucumber/messages'
import {
BinaryToMessageStream,
NdjsonToMessageStream,
} from '@cucumber/messages/dist/src/stream'
import { BinaryToMessageStream, NdjsonToMessageStream } from '@cucumber/message-streams'
import program from 'commander'

@@ -12,7 +9,3 @@ import p from '../package.json'

program.version(p.version)
program.option(
'-f, --format <format>',
'output format: ndjson|protobuf',
'protobuf'
)
program.option('-f, --format <format>', 'output format: ndjson|protobuf', 'protobuf')
program.parse(process.argv)

@@ -22,8 +15,4 @@

program.opts().format === 'ndjson'
? new NdjsonToMessageStream(
messages.Envelope.fromObject.bind(messages.Envelope)
)
: new BinaryToMessageStream(
messages.Envelope.decodeDelimited.bind(messages.Envelope)
)
? new NdjsonToMessageStream(messages.Envelope.fromObject.bind(messages.Envelope))
: new BinaryToMessageStream(messages.Envelope.decodeDelimited.bind(messages.Envelope))

@@ -30,0 +19,0 @@ pipeline(

@@ -14,6 +14,4 @@ import fs from 'fs'

*/
constructor(cssPath: string, jsPath: string) {
constructor(private readonly cssPath: string, private readonly jsPath: string) {
super({ objectMode: true })
this.cssPath = cssPath
this.jsPath = jsPath
}

@@ -41,4 +39,2 @@

private cssPath: string
private writePreMessageUnlessAlreadyWritten(callback: TransformCallback) {

@@ -62,4 +58,2 @@ if (this.preMessageWritten) {

private jsPath: string
private writePostMessage(callback: TransformCallback) {

@@ -92,4 +86,3 @@ this.writePreMessageUnlessAlreadyWritten((err) => {

if (err) return callback(err)
const beginIndex =
begin == null ? 0 : template.indexOf(begin) + begin.length
const beginIndex = begin == null ? 0 : template.indexOf(begin) + begin.length
const endIndex = end == null ? template.length : template.indexOf(end)

@@ -101,17 +94,11 @@ this.push(template.substring(beginIndex, endIndex))

private readTemplate(
callback: (error?: Error | null, data?: string) => void
) {
private readTemplate(callback: (error?: Error | null, data?: string) => void) {
if (this.template !== null) {
return callback(null, this.template)
}
fs.readFile(
__dirname + '/index.mustache.html',
{ encoding: 'utf-8' },
(err, template) => {
if (err) return callback(err)
this.template = template
return callback(null, template)
}
)
fs.readFile(__dirname + '/index.mustache.html', { encoding: 'utf-8' }, (err, template) => {
if (err) return callback(err)
this.template = template
return callback(null, template)
})
}

@@ -118,0 +105,0 @@

@@ -6,13 +6,7 @@ import { messages } from '@cucumber/messages'

async function renderAsHtml(
...envelopes: messages.IEnvelope[]
): Promise<string> {
return new Promise((resolve) => {
async function renderAsHtml(...envelopes: messages.IEnvelope[]): Promise<string> {
return new Promise((resolve, reject) => {
let html = ''
const sink: Writable = new Writable({
write(
chunk: any,
encoding: string,
callback: (error?: Error | null) => void
): void {
write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void {
html += chunk

@@ -24,6 +18,6 @@ callback()

const cucumberHtmlStream = new CucumberHtmlStream(
__dirname +
'/../node_modules/@cucumber/react/dist/src/styles/cucumber-react.css',
__dirname + '/../dist/main.js'
`${__dirname}/dummy.css`,
`${__dirname}/dummy.js`
)
cucumberHtmlStream.on('error', reject)
cucumberHtmlStream.pipe(sink)

@@ -49,10 +43,6 @@

const html = await renderAsHtml(e1)
assert(
html.indexOf(
`window.CUCUMBER_MESSAGES = [${JSON.stringify(e1.toJSON())}]`
) >= 0
)
assert(html.indexOf(`window.CUCUMBER_MESSAGES = [${JSON.stringify(e1.toJSON())}]`) >= 0)
})
it('writes one message to html', async () => {
it('writes two messages to html', async () => {
const e1 = messages.Envelope.create({

@@ -67,5 +57,3 @@ testRunStarted: messages.TestRunStarted.create({}),

html.indexOf(
`window.CUCUMBER_MESSAGES = [${JSON.stringify(
e1.toJSON()
)},${JSON.stringify(e2.toJSON())}]`
`window.CUCUMBER_MESSAGES = [${JSON.stringify(e1.toJSON())},${JSON.stringify(e2.toJSON())}]`
) >= 0

@@ -72,0 +60,0 @@ )

{
"compilerOptions": {
"declaration": true,
"target": "es5",
"lib": [
"es2019",
"dom"
],
"sourceMap": true,
"allowJs": false,
"jsx": "react",
"resolveJsonModule": true,
"module": "commonjs",
"esModuleInterop": true,
"noImplicitAny": true,
"moduleResolution": "node",
"outDir": "dist",
"downlevelIteration": true,
"skipLibCheck": true
},
"include": [
"src/**/*",
"test/**/*",
"features/**/*"
]
"extends": "../../tsconfig.json"
}

@@ -1,13 +0,3 @@

const path = require('path')
module.exports = {
entry: './src/main.tsx',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader'
}
]
}
entry: './dist/src/main.js',
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc