dimanche 4 mars 2018

How do I run a test file using ts-node?

Being fairly new to node and ts-node, I'm struggling to figure out how to run tests from this open source project -- https://github.com/pocesar/node-stratum (which are .ts files). I installed both "typescript" and "ts-node" ...

localhost:node-stratum satishp$ npm install -g typescript
/usr/local/bin/tsc -> /usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/bin/tsserver -> /usr/local/lib/node_modules/typescript/bin/tsserver
+ typescript@2.7.2
added 1 package in 2.974s


localhost:node-stratum satishp$ npm install -g ts-node
/usr/local/bin/ts-node -> /usr/local/lib/node_modules/ts-node/dist/bin.js
+ ts-node@5.0.1
added 17 packages in 1.596s

but when I go to run the tests, located in the "test/tests.ts" directory, I get teh following error

localhost:node-stratum satishp$ ts-node test/tests.ts
Error: Cannot find module '../lib'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/satishp/Documents/workspace/node-stratum/test/tests.ts:3:1)
    at Module._compile (module.js:660:30)
    at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:400:23)
    at Module._extensions..js (module.js:671:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:403:12)
    at Module.load (module.js:573:32)

Is there something more I need to do to get the test file to run properly?

Aucun commentaire:

Enregistrer un commentaire