2015-06-14 19 views
6

Ich befolge Sails-Dokumente und versuche, Mocha-Tests durchzuführen. Ich habe meine package.json in der Art und Weise, wie die Dokumente angegeben, aber aus irgendeinem Grund, wenn ich versuche, Mocha ausführen, ich bekomme immer EACESS, Erlaubnis verweigert Fehler.Fehler beim Ausführen von Mokkatests mit Segeln

Zuerst bekam ich:

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

Ich verstehe nicht, warum würde es meine Tests mit Laufen nichts zu tun hat, aber hinzugefügt, um die erforderliche Berechtigung für diesen Ordner.

dann bekam ich:

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

Wieder verstand nicht, so die Berechtigung für diesen Ordner geändert, was nicht auch geholfen haben.

Ich verstehe nicht, warum Mocha Berechtigungen für diese Dateien benötigen oder wie Sie es beheben können.

lief ich den Befehl:

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

Und meine Projektstruktur ist genau die gleiche wie in Sails Tutorials.

Ich verwende [email protected]. Mein Mitarbeiter klonte das Repo und versuchte, die Tests auf seiner Maschine auszuführen, scheiterte aber mit genau den gleichen Fehlern.

Ich versuchte Downgrade auf [email protected] Was auch nicht geholfen hat.

Der vollständige Fehlertrace:

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

Was bedeutet 'ls test/unit/**/* .test.js' machen? Es scheint, als könnte es einen Symlink zu '/ Library/Application Support /' irgendwo in Ihrem 'test /' Verzeichnis geben. – robertklep

+0

Das Ausführen des 'ls' Befehls gibt zurück:' test/unit/controllers/UserController.test.js test/unit/models/User.test.js', die meine zwei Testdateien sind. Ich habe dort bei der Suche keinen Symlink gesehen. – OmriToptix

+0

Vielleicht ist es ein Problem mit dem spezifischen Verzeichnis in Ihrem? Versuchen Sie, 'npm cache clean' und dann' npm install' erneut auszuführen und führen Sie den Befehl erneut aus und sehen Sie, ob es funktioniert. Wenn nicht, vielleicht versuchen, dirs zu wechseln? –

Antwort

1

Werfen Sie einen Blick auf meine sails.js test example. Ich denke, dass es dir helfen kann.

Wie im folgenden Code, siehe 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

Immer noch nicht geholfen. Das Ausführen des Befehls 'mocha' allein, unabhängig von Sails, gibt auch diesen Fehler der Berechtigung verweigert zurück. Ich denke, es hat nichts mit Sails zu tun. – OmriToptix

0

Ich bin mir nicht sicher, ob es helfen kann, aber ich hatte ein ähnliches Problem: sobald ich Mokka in meiner Shell eingegeben wurden sie mit einem EACCES auf einen Ordner außerhalb meiner App versagt. :

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

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

ich den Fehler gefunden aus der Datei kam ./test/mocha.opt i Kommentar waren von sails.js docs schrieb:

/** 
* @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