{"id":26581693,"url":"https://github.com/csteinba/node-red-contrib-flowtest","last_synced_at":"2025-08-12T09:10:21.511Z","repository":{"id":143898445,"uuid":"439471103","full_name":"csteinba/node-red-contrib-flowtest","owner":"csteinba","description":"Simple testing for your Node-RED flows.","archived":false,"fork":false,"pushed_at":"2022-01-27T20:49:02.000Z","size":446,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-26T01:25:33.121Z","etag":null,"topics":["node-red","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csteinba.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-17T22:03:15.000Z","updated_at":"2024-10-27T13:41:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"18bffb7c-1fd1-4c48-a4aa-d38070d7c547","html_url":"https://github.com/csteinba/node-red-contrib-flowtest","commit_stats":null,"previous_names":["csteinba/node-red-contrib-flowtest","steineey/node-red-contrib-flowtest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/csteinba/node-red-contrib-flowtest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csteinba%2Fnode-red-contrib-flowtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csteinba%2Fnode-red-contrib-flowtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csteinba%2Fnode-red-contrib-flowtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csteinba%2Fnode-red-contrib-flowtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csteinba","download_url":"https://codeload.github.com/csteinba/node-red-contrib-flowtest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csteinba%2Fnode-red-contrib-flowtest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270033300,"owners_count":24515475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node-red","testing"],"created_at":"2025-03-23T07:31:17.602Z","updated_at":"2025-08-12T09:10:21.463Z","avatar_url":"https://github.com/csteinba.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-red-contrib-flowtest\nSimple testing for your Node-RED flows.\n\n## Usage\nThis package will add two new node types to your node palette.\n* `test inject` which will inject a test message into your flow.\n* ... and an `assert` node which will catch this test message and make assertions about it.\n\n![example-flow](https://github.com/steineey/node-red-contrib-flowtest/blob/master/examples/flow.png)\n\nA single `test inject` node can define multiple test cases. A test message will behave like a 'real' message. The only difference is that a test message will be catched by the first `assert` node. The `assert` node executes a callback to the `test inject`, where the assertion about the resulting message is done.\n\nRun the test injection instant after re-deployment or with a message input. The test inject node will output the test result as debug output.\n\nThe nodes will give you a simple and intuitive feedback via node states.\n\nCredits: I'm not the first who came up with this kind of design. During development I found these  similar designs.\n* https://flows.nodered.org/node/node-red-contrib-flow-asserter\n* https://github.com/node-red/node-red/wiki/Flow-testing\n\n## Define Test Cases \n\nTest case script has to return an array ot test cases\n```\nreturn [\u003ctest-case-1\u003e, \u003ctest-case-2\u003e, ..., \u003ctest-case-n\u003e]\n```\n![example-flow](https://github.com/steineey/node-red-contrib-flowtest/blob/master/examples/inject-node.png)\n\n### Test Case Object\nlabel (string) : Test case label. \\\ninject (object) : Test message. \\\nassert (function(msg)) : Assert function. Define your test assertions with NodeJS - Assert or with [should](https://www.npmjs.com/package/should). \\\ntimeout (integer) : Timeout in miliseconds for the test case to timeout. Default is 2000ms, Max is 10000ms. \\\ndelay (integer) : Delay for the test case inject. Default is 100 ms.\n\n### Example\n\nTest Case Script\n```\nreturn [{\n  label: 'is lower case', \n  inject: {\n      payload: 'HELLO WORLD'\n  },\n  assert: function(msg){\n      should(msg).have.property('payload', 'hello world');\n  }\n}, {\n  label: 'msg payload is not null',\n  inject: {\n    payload: 'hello'\n  },\n  assert: function(msg) {\n      should(msg.payload).not.be.null();\n  }\n},{\n  label: 'wrong data type', \n  inject: {\n      payload: 123\n  },\n  assert: function(msg) {\n      should(msg).have.property('error');\n  }\n}]\n```\n\nflow.json \n```\n[{\"id\":\"3ba5305cbc00e173\",\"type\":\"tab\",\"label\":\"Flow Test\",\"disabled\":false,\"info\":\"\",\"env\":[]},{\"id\":\"ffe853e065f4a8e9\",\"type\":\"test inject\",\"z\":\"3ba5305cbc00e173\",\"name\":\"\",\"onstart\":true,\"tests\":\"return [{\\n    label: 'to lower case', \\n    inject: {\\n        payload: 'HELLO WORLD'\\n    },\\n    assert: function(msg){\\n        should(msg).have.property('payload', 'hello world');\\n    }\\n}, {\\n    label: 'msg payload not null',\\n    inject: {\\n        payload: 'hello'\\n    },\\n    assert: function(msg) {\\n        should(msg.payload).not.be.null();\\n    }\\n},{\\n    label: 'wrong data type', \\n    inject: {\\n        payload: 123\\n    },\\n    assert: function(msg) {\\n        should(msg).have.property('error');\\n    },\\n    delay: 1000\\n}];\",\"x\":280,\"y\":180,\"wires\":[[\"f2f18ecdccead0a8\"],[\"69a71b38768150a1\"]]},{\"id\":\"2ea8589458745f05\",\"type\":\"inject\",\"z\":\"3ba5305cbc00e173\",\"name\":\"input\",\"props\":[{\"p\":\"payload\"}],\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"topic\":\"\",\"payload\":\"HELLO WORLD\",\"payloadType\":\"str\",\"x\":270,\"y\":120,\"wires\":[[\"f2f18ecdccead0a8\"]]},{\"id\":\"f2f18ecdccead0a8\",\"type\":\"function\",\"z\":\"3ba5305cbc00e173\",\"name\":\"to lower case\",\"func\":\"msg.payload = msg.payload.toLowerCase();\\nreturn msg;\",\"outputs\":1,\"noerr\":0,\"initialize\":\"\",\"finalize\":\"\",\"libs\":[],\"x\":460,\"y\":140,\"wires\":[[\"1f2cbc42e45437fb\"]]},{\"id\":\"1f2cbc42e45437fb\",\"type\":\"assert\",\"z\":\"3ba5305cbc00e173\",\"name\":\"\",\"x\":630,\"y\":140,\"wires\":[[\"2e6f285e437cb0dc\"]]},{\"id\":\"b2568a8b9019cf6d\",\"type\":\"catch\",\"z\":\"3ba5305cbc00e173\",\"name\":\"\",\"scope\":null,\"uncaught\":false,\"x\":420,\"y\":260,\"wires\":[[\"5a29cf9d7e7d988c\"]]},{\"id\":\"5a29cf9d7e7d988c\",\"type\":\"assert\",\"z\":\"3ba5305cbc00e173\",\"name\":\"\",\"x\":570,\"y\":260,\"wires\":[[]]},{\"id\":\"2e6f285e437cb0dc\",\"type\":\"debug\",\"z\":\"3ba5305cbc00e173\",\"name\":\"output\",\"active\":true,\"tosidebar\":true,\"console\":false,\"tostatus\":false,\"complete\":\"payload\",\"targetType\":\"msg\",\"statusVal\":\"\",\"statusType\":\"auto\",\"x\":760,\"y\":140,\"wires\":[]},{\"id\":\"69a71b38768150a1\",\"type\":\"debug\",\"z\":\"3ba5305cbc00e173\",\"name\":\"\",\"active\":true,\"tosidebar\":true,\"console\":false,\"tostatus\":false,\"complete\":\"false\",\"statusVal\":\"\",\"statusType\":\"auto\",\"x\":450,\"y\":200,\"wires\":[]}]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsteinba%2Fnode-red-contrib-flowtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsteinba%2Fnode-red-contrib-flowtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsteinba%2Fnode-red-contrib-flowtest/lists"}