npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-flow-asserter-full-msg

v0.4.1

Published

This module is a node module that supports flow testing on the Node-RED editor UI. You can test the flow with multiple test-cases and without any changes when switching between test and production.

Downloads

2

Readme

node-red-contrib-flow-asserter

THIS IS A FORK FROM THE ORIGINAL PROJECT IN THIS URL. I CHANGED IT TO BE ABLE TO CREATE FULL MSGS, NOT JUST MSG.PAYLOADS

This module is a node module that supports flow testing on the Node-RED editor UI.

Description

node-red-contrib-flow-asserter is a node module that assists in testing the Node-RED flow in the editor.

When using Node-RED, the user creates a flow by connecting several nodes on the editor. And many users will test that the flow is doing what they want. How do you run the tests at this time? Is it like you check debug node by pressing the inject node's button, change the value and try again? In some cases, you may want to rewire the wire of the node just before the debug node so that unnecessary flows are not executed during the test. In addition, once you have modified your flow after starting production, you may need to repeat the test with all values again. In any case, Node-RED can be very annoying when trying to test a flow.

This module eliminates the hassle of such a flow test. There are two features of node-red-contrib-flow-asserter.

  1. Multiple test-cases can be executed with a single button click operation.
  2. During test execution, no message is sent to the flow after the position where the value is to be asserted.

The first feature eliminates the need for the user to rewrite the value of inject node many times for the test.

testcases

Describe multiple test cases in the node's edit dialog as shown above. Set the input value, value assertion method, and output value in the test case. In addition to the simple ==, the value assertion method are greater, lesser and the fast-deep-equal module's equals. By preparing multiple test cases with values set in this way, you can execute them all in one operation.

The second feature is that it saves you the trouble of modifying the flow when switching between test execution and production execution. The figure below shows a simple flow using this node.

flow-asserter

This module has 2 nodes, flow-asserter in node(the node with button) and flow-asserter out node(the node with one input port and one output port). The test is executed by clicking the button of flow-asserter in node, and the message object with the test case input value substituted in payload is sent from the upper port. The message reaches flow-asserter out node via delay node and function node. Flow-asserter out node then does not send the message to debug node connected to its output port. Instead of that, the node verifies the value. The verification result is sent from the lower port of flow-asserter in node. So what happens if you run it not during testing? As explained in the previous example, when the button of inject node is pressed, flow-asserter out node is reached via delay node and function node, but here the value verification is not performed and the message is passed to debug node without doing anything.

Usage

Following example flow is in examples/example.json.
Drag & drop in your Node-RED editor.

  1. Prepare the test object flow.
    In this example, the flow consists of inject node, delay node, function node and debug node. This flow sends string, converts msg.payload to uppercase and display that. intactflow

  2. Flow-asserter out node is dragged over the mid-point of a wire which links between function node and debug node. The reason is we want to ensure the letters becoming the uppercase.

  3. Add flow-asserter in node to the workspace. The upper output port of the node is wired to the input port of delay node and the lower output port is wired to the input port of debug node which is newly added. assertflow

  4. Open the edit dialog of flow-asserter in node. Push add button 3 times for making 3 test cases. Fill input and output like the below figure. Second row of test-case, testID 1, will fails. Finally select flow-asserter out node's ID at the bottom of the dialog. edit-dialog

  5. Save and close the dialog. In workspace, click the button of flow-asserter in node. Test will start, node status is displayed and test-case's result is displayed in debug sidebar. Second test-case, testID 1, will be failure and the others will be success.
    test-finished
    debug-sidebar

  6. Check the movement of messages during test execution. When you click the button of flow-asserter in node, the test-case in the first line set in the edit dialog will be executed. The test-case input value is assigned to msg.payload and the message is sent from the upper output port. When flow-asserter out node is reached, the message is not sent to debug node connected to the output port, but sent to flow-asserter in node, and the value is verified according to the test-case description. The verification result is sent from the lower output port of flow-asserter in node. At the same time, the test-case in the second line is executed. This is repeated until all test-cases have been executed.

  7. Finally, just in case, check the behavior during normal execution that is not a test. When you click the button of inject node, the value is substituted into msg.payload and a message is sent. A message arrives at flow-asserter out node on the way, but since the test is not in progress, it passes the message to debug node connected to the output port without performing any processing.

Install

npm install node-red-contrib-flow-asserter

NPM

Changelog

Changelog

Licence

Apache-2.0

Author

s1r-J

Languages

日本語README