2015-06-14 20 views
6

Tôi đang theo dõi tài liệu Sails và cố chạy thử nghiệm Mocha. Tôi đã chỉnh sửa package.json theo cách tài liệu được chỉ định, nhưng vì một lý do nào đó khi tôi cố gắng chạy Mocha, tôi luôn nhận được EACESS, sự cho phép bị từ chối lỗi.không chạy thử nghiệm mocha với buồm

Lúc đầu, tôi nhận được:

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

Tôi không hiểu tại sao nó sẽ phải làm gì với chạy thử nghiệm của tôi, nhưng gia tăng sự cho phép cần thiết cho thư mục này.

sau đó tôi nhận:

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

Một lần nữa, không hiểu, vì vậy thay đổi sự cho phép trên thư mục này, mà không giúp cũng có.

Tôi không hiểu tại sao Mocha cần quyền trên các tệp này hoặc cách khắc phục.

Tôi chạy lệnh:

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

Và cấu trúc dự án của tôi là chính xác giống như trong Sails hướng dẫn.

Tôi đang sử dụng [email protected]. Đồng nghiệp của tôi nhân bản repo, và cố gắng chạy các thử nghiệm trên máy của mình, nhưng không thành công với chính xác cùng một lỗi.

Tôi đã cố gắng hạ cấp xuống [email protected] Điều nào cũng không giúp ích gì.

Các lỗi dấu vết đầy đủ:

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

gì 'ls test/unit/**/* .test.js' làm gì? Có vẻ như có thể có một liên kết tượng trưng đến '/ Library/Application Support /' ở đâu đó trong thư mục 'test /' của bạn. – robertklep

+0

Chạy lệnh 'ls' trả về:' test/unit/controllers/UserController.test.js test/unit/models/User.test.js' là hai tệp thử nghiệm của tôi. Tôi không thấy bất kỳ liên kết tượng trưng nào khi tìm kiếm. – OmriToptix

+0

có thể đó là vấn đề với thư mục cụ thể của bạn? thử chạy 'npm cache clean' và sau đó' npm install' một lần nữa và chạy lại lệnh và xem nó có hoạt động không. Nếu không, có thể thử chuyển đổi dirs? –

Trả lời

1

Hãy xem sails.js test example tôi. Tôi nghĩ rằng nó có thể giúp bạn.

Như trong mã được hiển thị bên dưới, hãy tham khảo 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

Vẫn không hiệu quả. Chạy lệnh 'mocha' của chính nó, bất kể Sails cũng trả về lỗi này cho phép từ chối. Tôi đoán nó không liên quan gì đến Sails. – OmriToptix

0

Tôi không chắc liệu nó có thể giúp ích hay không: ngay khi tôi nhập mocha vào vỏ, nó thất bại với EACCES trên thư mục bên ngoài ứng dụng của tôi. :

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

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

Tôi tìm thấy lỗi xuất phát từ tập tin ./test/mocha.opt là tôi đã viết một bình luận từ sails.js tài liệu:

/** 
* @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 
Các vấn đề liên quan