lundi 14 octobre 2019

problems including require modules with NativeScript unit tests

I set up my NativeScript environment to include unit tests some time back. This worked well back in the day, but I haven't used unit tests for several months, and there have been {N} updates made since. I recently returned my attention to this discipline, but I find I now have a problem with requiring modules.

A simple sanity check test that brings in a simple file that exports a string:

const MyHost = require('~/my-host.js')

results in the error:

Error: com.tns.NativeScriptException: Failed to find module: "~/my-host.js", relative to: /app/
    com.tns.Module.resolvePathHelper(Module.java:151)
    com.tns.Module.resolvePath(Module.java:56)

and attempts to change from the use of the tilde (~), such as simply 'my-host.js', or ('../app/my-host.js') or other variants also result in path resolution errors.

What changed, and how do I fix it?

Aucun commentaire:

Enregistrer un commentaire