Socket
Socket
Sign inDemoInstall

@cucumber/cucumber

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cucumber/cucumber - npm Package Compare versions

Comparing version 9.2.0 to 9.3.0

10

lib/formatter/helpers/test_case_attempt_formatter.js

@@ -74,4 +74,10 @@ "use strict";

if ((0, value_checker_1.valueOrDefault)(printAttachments, true)) {
attachments.forEach(({ body, mediaType }) => {
const message = mediaType === 'text/plain' ? `: ${body}` : '';
attachments.forEach(({ body, mediaType, fileName }) => {
let message = '';
if (mediaType === 'text/plain') {
message = `: ${body}`;
}
else if (fileName) {
message = `: ${fileName}`;
}
text += (0, indent_string_1.default)(`Attachment (${mediaType})${message}\n`, 4);

@@ -78,0 +84,0 @@ });

21

lib/runtime/attachment_manager/index.d.ts

@@ -12,8 +12,13 @@ /// <reference types="node" />

media: IAttachmentMedia;
fileName?: string;
}
export type IAttachFunction = (attachment: IAttachment) => void;
export type ICreateStringAttachment = (data: string, mediaType?: string) => void;
export type ICreateBufferAttachment = (data: Buffer, mediaType: string) => void;
export type ICreateStreamAttachment = (data: Readable, mediaType: string) => Promise<void>;
export type ICreateStreamAttachmentWithCallback = (data: Readable, mediaType: string, callback: () => void) => void;
export interface ICreateAttachmentOptions {
mediaType: string;
fileName?: string;
}
export type ICreateStringAttachment = (data: string, mediaTypeOrOptions?: string | ICreateAttachmentOptions) => void;
export type ICreateBufferAttachment = (data: Buffer, mediaTypeOrOptions: string | ICreateAttachmentOptions) => void;
export type ICreateStreamAttachment = (data: Readable, mediaTypeOrOptions: string | ICreateAttachmentOptions) => Promise<void>;
export type ICreateStreamAttachmentWithCallback = (data: Readable, mediaTypeOrOptions: string | ICreateAttachmentOptions, callback: () => void) => void;
export type ICreateAttachment = ICreateStringAttachment & ICreateBufferAttachment & ICreateStreamAttachment & ICreateStreamAttachmentWithCallback;

@@ -25,6 +30,6 @@ export type ICreateLog = (text: string) => void;

log(text: string): void | Promise<void>;
create(data: Buffer | Readable | string, mediaType?: string, callback?: () => void): void | Promise<void>;
createBufferAttachment(data: Buffer, mediaType: string): void;
createStreamAttachment(data: Readable, mediaType: string, callback: () => void): void | Promise<void>;
createStringAttachment(data: string, media: IAttachmentMedia): void;
create(data: Buffer | Readable | string, mediaTypeOrOptions?: string | ICreateAttachmentOptions, callback?: () => void): void | Promise<void>;
createBufferAttachment(data: Buffer, mediaType: string, fileName?: string): void;
createStreamAttachment(data: Readable, mediaType: string, fileName?: string, callback?: () => void): void | Promise<void>;
createStringAttachment(data: string, media: IAttachmentMedia, fileName?: string): void;
}

@@ -39,24 +39,25 @@ "use strict";

}
create(data, mediaType, callback) {
create(data, mediaTypeOrOptions, callback) {
const options = normaliseOptions(mediaTypeOrOptions);
if (Buffer.isBuffer(data)) {
if ((0, value_checker_1.doesNotHaveValue)(mediaType)) {
if ((0, value_checker_1.doesNotHaveValue)(options.mediaType)) {
throw Error('Buffer attachments must specify a media type');
}
this.createBufferAttachment(data, mediaType);
this.createBufferAttachment(data, options.mediaType, options.fileName);
}
else if (is_stream_1.default.readable(data)) {
if ((0, value_checker_1.doesNotHaveValue)(mediaType)) {
if ((0, value_checker_1.doesNotHaveValue)(options.mediaType)) {
throw Error('Stream attachments must specify a media type');
}
return this.createStreamAttachment(data, mediaType, callback);
return this.createStreamAttachment(data, options.mediaType, options.fileName, callback);
}
else if (typeof data === 'string') {
if ((0, value_checker_1.doesNotHaveValue)(mediaType)) {
mediaType = 'text/plain';
if ((0, value_checker_1.doesNotHaveValue)(options.mediaType)) {
options.mediaType = 'text/plain';
}
if (mediaType.startsWith('base64:')) {
if (options.mediaType.startsWith('base64:')) {
this.createStringAttachment(data, {
encoding: messages.AttachmentContentEncoding.BASE64,
contentType: mediaType.replace('base64:', ''),
});
contentType: options.mediaType.replace('base64:', ''),
}, options.fileName);
}

@@ -66,4 +67,4 @@ else {

encoding: messages.AttachmentContentEncoding.IDENTITY,
contentType: mediaType,
});
contentType: options.mediaType,
}, options.fileName);
}

@@ -75,9 +76,9 @@ }

}
createBufferAttachment(data, mediaType) {
createBufferAttachment(data, mediaType, fileName) {
this.createStringAttachment(data.toString('base64'), {
encoding: messages.AttachmentContentEncoding.BASE64,
contentType: mediaType,
});
}, fileName);
}
createStreamAttachment(data, mediaType, callback) {
createStreamAttachment(data, mediaType, fileName, callback) {
const promise = new Promise((resolve, reject) => {

@@ -89,3 +90,3 @@ const buffers = [];

data.on('end', () => {
this.createBufferAttachment(Buffer.concat(buffers), mediaType);
this.createBufferAttachment(Buffer.concat(buffers), mediaType, fileName);
resolve();

@@ -102,7 +103,22 @@ });

}
createStringAttachment(data, media) {
this.onAttachment({ data, media });
createStringAttachment(data, media, fileName) {
this.onAttachment({
data,
media,
...(fileName ? { fileName } : {}),
});
}
}
exports.default = AttachmentManager;
function normaliseOptions(mediaTypeOrOptions) {
if (!mediaTypeOrOptions) {
return {};
}
if (typeof mediaTypeOrOptions === 'string') {
return {
mediaType: mediaTypeOrOptions,
};
}
return mediaTypeOrOptions;
}
//# sourceMappingURL=index.js.map

@@ -37,3 +37,3 @@ "use strict";

constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries = 0, skip, filterStackTraces, supportCodeLibrary, worldParameters, }) {
this.attachmentManager = new attachment_manager_1.default(({ data, media }) => {
this.attachmentManager = new attachment_manager_1.default(({ data, media, fileName }) => {
if ((0, value_checker_1.doesNotHaveValue)(this.currentTestStepId)) {

@@ -47,2 +47,3 @@ throw new Error('Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.');

mediaType: media.contentType,
fileName,
testCaseStartedId: this.currentTestCaseStartedId,

@@ -49,0 +50,0 @@ testStepId: this.currentTestStepId,

@@ -1,1 +0,1 @@

export declare const version = "9.2.0";
export declare const version = "9.3.0";

@@ -5,3 +5,3 @@ "use strict";

// Generated by genversion.
exports.version = '9.2.0';
exports.version = '9.3.0';
//# sourceMappingURL=version.js.map

@@ -11,3 +11,3 @@ {

],
"version": "9.2.0",
"version": "9.3.0",
"homepage": "https://github.com/cucumber/cucumber-js",

@@ -216,3 +216,3 @@ "author": "Julien Biezemans <jb@jbpros.com>",

"@cucumber/gherkin-utils": "8.0.2",
"@cucumber/html-formatter": "20.3.0",
"@cucumber/html-formatter": "20.4.0",
"@cucumber/message-streams": "4.0.1",

@@ -242,3 +242,3 @@ "@cucumber/messages": "22.0.0",

"resolve-pkg": "^2.0.0",
"semver": "7.3.8",
"semver": "7.5.3",
"string-argv": "^0.3.1",

@@ -255,3 +255,3 @@ "strip-ansi": "6.0.1",

"devDependencies": {
"@cucumber/compatibility-kit": "11.3.0",
"@cucumber/compatibility-kit": "^12.0.0",
"@cucumber/query": "12.0.1",

@@ -277,3 +277,3 @@ "@microsoft/api-documenter": "7.19.27",

"@types/progress": "2.0.5",
"@types/semver": "7.3.13",
"@types/semver": "7.5.0",
"@types/sinon-chai": "3.2.9",

@@ -280,0 +280,0 @@ "@types/sinonjs__fake-timers": "8.1.2",

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