2015-06-14 13 views
6

Sto seguendo i documenti di Sails e ho provato ad eseguire i test di Mocha. Ho modificato il mio package.json nel modo specificato dai documenti, ma per qualche motivo quando provo a eseguire Mocha ottengo sempre EACESS, errore di autorizzazione negato.fallimento nell'esecuzione di test di moka con le vele

In un primo momento ho avuto:

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

non ho capire perché sarebbe ha a che fare tutto ciò con l'esecuzione di mio test, ma ha aggiunto l'autorizzazione necessaria per questa cartella.

poi ho ricevuto:

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

Anche in questo caso, non ha capito, così cambiato il permesso per questa cartella, che non ha aiutato anche.

Non sto capendo perché Mocha avrebbe bisogno di autorizzazioni su questi file, o come risolverlo.

Ho eseguito il comando:

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

E la mia struttura del progetto è esattamente lo stesso come in Sails tutorial.

Sto usando [email protected]. Il mio collega ha clonato il repository e ha provato a eseguire i test sulla sua macchina, ma ha fallito esattamente con gli stessi errori.

Ho provato il downgrade a [email protected] Che non ha aiutato anche.

La traccia di errore completo:

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. 
+0

Cosa significa 'ls test/unit/**/* .test.js' fare? Sembra che potrebbe esserci un link simbolico a '/ Library/Application Support /' da qualche parte nella tua directory 'test /'. – robertklep

+0

Esegue il comando 'ls' restituisce:' test/unit/controller/UserController.test.js test/unit/models/User.test.js' che sono i miei due file di test. Non ho visto nessun collegamento simbolico lì durante la ricerca. – OmriToptix

+0

forse è un problema con la directory specifica il tuo in? prova a eseguire 'npm cache clean' e quindi' npm install' di nuovo ed eseguire di nuovo il comando e vedere se funziona. Se no, magari provare a cambiare dirs? –

risposta

1

Date un'occhiata al mio sails.js test example. Penso che possa aiutarti.

Come nel codice riportato di seguito, fare riferimento a 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); 
}); 
+0

Ancora non aiuta. Eseguendo il comando 'mocha' da solo, indipendentemente da Sails restituisce anche questo errore di autorizzazione negato. Immagino che non abbia niente a che fare con Sails. – OmriToptix

0

non sono sicuro se può aiutare, ma ho avuto un problema simile: non appena ho digitato moka nel mio guscio, fosse venendo a mancare con un EACCES su una cartella al di fuori della mia app. :

/usr/local/lib/node_modules/mocha/bin/_mocha:372 
    throw err; 
    ^

Error: EACCES: permission denied, scandir '/backup/mint17.3/etc/cups/ssl' 

Ho trovato il bug è venuto da file ./test/mocha.opt fossi ho scritto un commento da 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 
Problemi correlati