thingworx-field-work / ThingworxVSCodeProject

Develop thingworx models using a real IDE
MIT License
33 stars 17 forks source link

[Question] Is there any way to write unit tests? #62

Open makon opened 11 months ago

makon commented 11 months ago

Hi, I am wondering if there is any way to write unit tests for the TypeScript code?

I was experimenting a lot with different solutions but none of them worked. Mostly they failed because of missing modules and as soon as I tried to introduce some kind of modules the Generated.d.ts failed.

So maybe you guys have any solution in mind how it would be possible to write some unit tests for it?

BogdanMihaiciuc commented 11 months ago

This doesn't offer anything specific in regards to unit tests and I also don't have any good workarounds to do them.

What I've seen most people do in thingworx is to just write separate test services and run them on a thingworx server. This project template doesn't really let you do anything special with that, except maybe using the @ifenv decorator to exclude test entities from production builds.

What kind of modules are you trying to include?

You won't really be able to include and compile them via the cli tools because import and require statements don't work with the project structure (everything is global). For many frameworks it's also likely that they won't work in the thingworx runtime since many of them expect to be run in node.