where Business Processes, Data and Rules meet.
Blog
Home / Business Rule / Test Business Rules in JavaScript

Test Business Rules in JavaScript

0

How to Test Business Rules in JavaScript Environment

Modeling business rules in a Decision Table or Natural Language allows you to deploy them to your JavaScript platform and execute them inside your service or app (i.e., Browser, NodeJS, etc).

Test Without App

You also can test and debug these business rules directly inside FlexRule Designer. But how do you test business rules in JavaScript environment without having an application or service to run them? It’s very important that you are able to pass your JSON objects to business rules in a JavaScript environment and play with it in order to see their impact. In this way, you can be confident about how well they work before putting them inside your application.

Let’s build a simple Decision Table like the one below (you can also model the same rules in Natural Language):

Test Business Rules in JavaScript

Returns Title for a person based on Person’s Age

Now what? In the Debug menu select JS Test Bed. This launches a JavaScript web-based application that allows you to test your business rules in JavaScript:

Test Business Rules in JavaScript

Not only that, it also automatically defines the Input Parameters (e.g., Person) in a visual JSON editor that allows you to add the Age with a value for the person:

Test Business Rules in JavaScript

And just press Run Logic and you will see the results. Just for fun, we will add an age of 101 and see what happens:

Test Business Rules in JavaScript

As you can see, in the results panel you can even inspect the notification messages as well.

Conclusion

The JS Test Bed is a simple web application that allows you to play with and test business rules in the JavaScript environment when they are written in a Decision Table and Natural Language. So the next time you want to test your business rules in JavaScript environment, you don’t need to wait for your platform, application, and so on to become ready! Everything is ready for you to just focus on your business rules and model, debug, test and deploy them. Start it today.

Recommended Posts

Leave a Comment

You must be logged in to post a comment
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.