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

@cucumber/message-streams

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cucumber/message-streams

Streams for reading/writing messages

  • 4.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
693K
decreased by-39.5%
Maintainers
2
Weekly downloads
 
Created

What is @cucumber/message-streams?

@cucumber/message-streams is a package that provides utilities for working with Cucumber messages in a streaming fashion. It allows you to read, write, and transform Cucumber messages using streams, which can be useful for processing large sets of test results or integrating with other tools.

What are @cucumber/message-streams's main functionalities?

Reading Cucumber Messages from a Stream

This feature allows you to read Cucumber messages from a NDJSON (Newline Delimited JSON) stream. The code sample demonstrates how to create a readable stream from a file and pipe it through the NdjsonToMessageStream to process each message.

const { NdjsonToMessageStream } = require('@cucumber/message-streams');
const fs = require('fs');

const inputStream = fs.createReadStream('cucumber.ndjson');
const messageStream = new NdjsonToMessageStream();

inputStream.pipe(messageStream).on('data', (message) => {
  console.log(message);
});

Writing Cucumber Messages to a Stream

This feature allows you to write Cucumber messages to a NDJSON stream. The code sample demonstrates how to create a writable stream to a file and use the MessageToNdjsonStream to write a Cucumber message to the file.

const { MessageToNdjsonStream } = require('@cucumber/message-streams');
const fs = require('fs');

const outputStream = fs.createWriteStream('output.ndjson');
const messageStream = new MessageToNdjsonStream();

messageStream.pipe(outputStream);

messageStream.write({
  type: 'TestRunStarted',
  timestamp: new Date().toISOString()
});

messageStream.end();

Transforming Cucumber Messages

This feature allows you to transform Cucumber messages as they are read from a stream and written to another stream. The code sample demonstrates how to create a transform stream that adds a custom property to each message and then pipes the messages through the transformation.

const { Transform } = require('stream');
const { NdjsonToMessageStream, MessageToNdjsonStream } = require('@cucumber/message-streams');
const fs = require('fs');

const inputStream = fs.createReadStream('cucumber.ndjson');
const outputStream = fs.createWriteStream('transformed.ndjson');

const transformStream = new Transform({
  objectMode: true,
  transform(message, encoding, callback) {
    // Example transformation: add a custom property
    message.customProperty = 'customValue';
    callback(null, message);
  }
});

inputStream
  .pipe(new NdjsonToMessageStream())
  .pipe(transformStream)
  .pipe(new MessageToNdjsonStream())
  .pipe(outputStream);

Other packages similar to @cucumber/message-streams

FAQs

Package last updated on 16 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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