node.js - node js module not found for directory of tape tests -


i have following structure:

src/examples/test_file.js src/test/example.test.js 

package.json:

  "scripts": {     "test": "node ./test/*.test.js"   }, 

i have tape installed via npm install tape --save

i run npm test , get:

> node ./test/*.test.js  module.js:328     throw err;     ^  error: cannot find module 'c:\src\test\*.test.js'     @ function.module._resolvefilename (module.js:326:15)     @ function.module._load (module.js:277:25)     @ function.module.runmain (module.js:430:10)     @ startup (node.js:141:18)     @ node.js:1003:3 npm err! test failed.  see above more details. 

per this: https://ci.testling.com/guide/tape

tests on whole dir should work global install of node package. how can above work without globally installing tape?

i using node 5.4 , windows 10

edit:

this works fine me on mac, , works fine on linux build server. assuming windows related

how can set other file run other tests?

one option list of files in test directory , execute node command each. assuming following test.js, run every file matching pattern specified.

var fs = require('fs-extra')   //child_process `exec` let normal bash-style executions   //eg, exec('ls') programmatically entering ls command   //into terminal window   , exec = require("child_process").exec;  //callback after our exec process finishes function execcallback(error, stdout, stderr) {    console.log(stdout); } fs.readdir give list of files in current ('.') directory var testfiles = fs.readdir('.', function(err, files){   if (err){     console.log('error reading files', err);   }else{     //use regex reduce list of files     //adhere pattern specified using wildcar "*.test.js"     files.filter(function(file){       return /^.*?\.test\.js/.test(file)     })     //filter returns reduced array passed     //this foreach loop use our `exec` command execute     //the shell command `node xxxxxx.test.js` every file in array created     .foreach(function(testfile){       exec('node ' + testfile, execcallback);     });   } }); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -