Failure to launch mocha tests with sails

I follow Sails docs and tried to run Mocha tests. I edited my package.json in the way the docs indicated, but for some reason, when I try to start Mocha, I always get EACESS, permission is denied.

First I got:

 Error: EACCES, permission denied '/Library/Application Support/Apple/ParentalControls/Users' 

I did not understand why he needed to do something with the execution of my tests, but the necessary permission was added for this folder.

then I got:

 Error: EACCES, permission denied '/Library/Application Support/ApplePushService' 

Again, I did not understand, so I changed the permission for this folder, which also did not help.

I don’t understand why Mocha needs permissions for these files or how to fix it.

I ran the command:

 mocha test/bootstrap.test.js test/unit/**/*.test.js 

And my project structure is exactly the same as in Sails tutorials.

I am using Mocha@2.2.5 . My employee cloned a repo and tried to run tests on his machine, but could not with exactly the same errors.

I tried downgrading to Mocha@2.2.0 , which didn't help either.

Full error tracing:

 events.js:85 throw er; // Unhandled 'error' event ^ Error: EACCES, permission denied '/Library/Application Support/ApplePushService' at Error (native) at Object.fs.readdirSync (fs.js:761:18) at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:609:20) at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15) at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:427:14) at Array.forEach (native) at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:426:9) at Glob._afterReaddir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:635:15) at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:613:17) at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15) at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:427:14) at Array.forEach (native) at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:426:9) at Glob._afterReaddir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:635:15) at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:613:17) at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15) at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:427:14) at Array.forEach (native) at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:426:9) at Glob._afterReaddir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:635:15) at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:613:17) at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15) at Glob.iterator (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:171:10) at Array.forEach (native) at new Glob (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:169:22) at glob (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:57:11) at Function.globSync (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:76:10) at Object.lookupFiles (/usr/local/lib/node_modules/mocha/lib/utils.js:590:20) at /usr/local/lib/node_modules/mocha/bin/_mocha:320:30 at Array.forEach (native) at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:319:6) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3 npm ERR! Test failed. See above for more details. 
+6
source share
2 answers

Take a look at my sails.js example for testing . I think this may help you.

As in the code below, refer to test / bootstrap.js .

 var Sails = require('sails'); var _ = require('lodash') global.DOMAIN = 'http://localhost'; global.PORT = 1420; global.HOST = DOMAIN + ':' + PORT; before(function(callback) { this.timeout(7000); var configs = { log: { level: 'info' }, connections: { memory: { // lets use memory tests ... adapter : 'sails-memory' } }, models: { connection: 'memory' }, port: PORT, environment: 'test', // @TODO needs suport to csrf token csrf: false, // we dont need this configs in API test hooks: { grunt: false, socket: false, pubsub: false } }; Sails.load(configs, function(err, sails) { if (err) { console.error(err); return callback(err); } console.log('rodo!') // here you can load fixtures, etc. callback(err, sails); }); }); after(function(done) { // here you can clear fixtures, etc. sails.lower(done); }); 
+1
source

I'm not sure if this can help, but I had a similar problem: as soon as I typed mocha in my shell, it failed with EACCES in a folder outside of my application.

 /usr/local/lib/node_modules/mocha/bin/_mocha:372 throw err; ^ Error: EACCES: permission denied, scandir '/backup/mint17.3/etc/cups/ssl' 

I found that the error came from a file. /test/mocha.opt, I wrote a comment from sails.js docs:

 /** * @Doc :: This file should contain mocha configuration as described here: https://mochajs.org/#mochaopts * * Note: The default test-case timeout in Mocha is 2 seconds. Increase * the timeout value in mocha.opts to make sure the sails lifting completes * before any of the test-cases can be started. */ --timeout 5s 
0
source

Source: https://habr.com/ru/post/989092/


All Articles