cancel
Showing results for 
Search instead for 
Did you mean: 

XSJS Unit Testing: require is not defined

pjespinosa
Explorer
0 Kudos

Dear All,

I am trying to test a .xsjs file via Unit Testing, but the test spec cannot locate the .xsjs file (please see attachment).

I have tried several alternatives:

require("attachments")
require("attachments.xsjs")
require("./attachments.xsjs")
require("../attachments.xsjs")
require("../../lib/attachments.xsjs")

etc..

Hopefully someone from the Community has come across this issue before and is able to help.

Many thanks

Regards

Pedro Espinosa

View Entire Topic
pfefferf
Active Contributor

require, as you know it from Node.js, requires CommonJS modules. XSJS itself does not follow CommonJS and does not know the require function. XSJS has an own "module loader" (if you wanna call it so); it is the $.import function. Please check the docu and example here.

pjespinosa
Explorer
0 Kudos

Many thanks Florian, I will test and let you know how it goes.

Regards

Pedro