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

rt-test-probe

v1.0.4

Published

Testing of capsules in an RT application using the TCPServer library

Downloads

12

Readme

rt-test-probe

JavaScript implementation of a test probe for testing real-time applications created with DevOps Model RealTime.

This repo contains a few JavaScript utilities (in the file testProbe.js) which let you send and invoke events to a real-time application that uses the TcpServer library. It also allows you intercept outgoing events sent or invoked by the real-time application.

Although this can be used as a means for general interaction with a real-time application from a JavaScript application, the main intended use case is to support testing of a real-time application. You can for example use the popular Mocha testing framework to write test cases for your real-time applications.

In the models folder you will find a few sample models, created with Model RealTime, which all are variants of the traffic-light-web sample application. In the test folder there are some Mocha tests for testing those models (both module testing, and unit testing of individual capsules).

Feel free to extend testProbe.js to cover your testing needs, whether you are using Mocha or another testing framework. Pull requests are welcome!

Steps for running a Mocha capsule unit test

  1. Start Model RealTime and import the "TrafficLight" project (located in the trafficlight-demo folder).
  2. Build the TC it contains (app.tcjs). Note that it's set-up to build the application using Visual Studio and links with the prebuilt version of the TcpServer library that is part of Model RealTime. You need to update the TC if you want to use another target configuration.
  3. Launch the built executable from Model RealTime or from the command-line. If you run it from the command-line start it like this:
executable.EXE -URTS_DEBUG=quit
  1. You will see a printout similar to this:
RT C++ Target Run Time System - Release 8.0.02

targetRTS: observability listening not enabled
  Task 0 detached
TrafficLight starts up
Out message: { "event" : "lightChanged" , "type" : "RTString" , "data" : "RTString\"Red\"", "command" : "sendEvent", "priority" : "General", "port" : "trafficLight_control", "portIndex" : 0}
Error: Failed to write to socket for 127.0.0.1@2234: Connection refused: 127.0.0.1:2234

This just shows that the application sent the "lightChanged" event but failed to deliver it to the test application since it's not yet running.

  1. Before you can start the test application you need to go to the rt-test-probe folder and run the command
npm install

This requires that you have Node.js installed.

  1. Now you can run some unit tests for the TrafficLight capsule of the RT application that you launched. From the command-line you can do this:
D:\github\HCL-TECH-SOFTWARE\rt-test-probe>npm test test/TrafficLight_unit2.js

> [email protected] test D:\github\HCL-TECH-SOFTWARE\rt-test-probe
> mocha "test/TrafficLight_unit2.js"



  TrafficLight
    √ should initially be in the Red state
    √ should be in the Green state after we have sent the Green event
    √ should ask for the duration of inactivity when we send the "deactivateLight" event, be inactive for the returned duration, and finally go back to the Green state (5026ms)


  3 passing (5s)

You can also try with the test in TrafficLight_unit3.js. If you are a Visual Studio Code user there is a launch.json file here which lets you debug the Mocha tests from within Visual Studio Code.