How to mock JSRecord and bounded relations

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

How to mock JSRecord and bounded relations

Postby 258.d.852 » Tue Jan 16, 2024 1:23 am

Dear Servoy community,

Supposedly, I have a public function in a scope that receives a JSRecord object, so-called currentRecord as an argument. In my implementation, I used currentRecord's bounded relation to another table, so-called the_table_foo_to_the_table_bar, to loop through and search for necessary record.

How can I mock the JSRecord as well as its bounded relation while testing?

My first idea is to define a concret object like this

Code: Select all
var mockedCurrentRecord = [{attribute_0: value_0,  attribute_1: value_1}];


and then pass it in the testing function. But when executing the test I got the error of
TypeError: Cannot call method "forEach" of undefined



Could you guys help me please?
258.d.852
 
Posts: 10
Joined: Wed Jul 12, 2023 1:10 pm

Return to Programming with Servoy

Who is online

Users browsing this forum: Bing [Bot] and 25 guests

cron