Tôi đang cố gắng để mô-đun nodeunit hoạt động trong một dự án coffeescript nhưng dường như không thể chạy thử nghiệm cơ bản. Dưới đây là ví dụ của tôi Coffeescript require 'nodeunit'Làm thế nào để sử dụng mô-đun node.js 'nodeunit' với các tệp coffeescript
test = true
test2 = false
exports.testSomething = (test) ->
test.expect(1)
test.ok(true, "this should pass")
test.done()
exports.testSomethingElse = (test2) ->
test2.expect(1)
test2.ok(false, "this should fail")
test2.done()
Thật không may, khi tôi chạy '$ nodeunit example.coffee' Tôi nhận được đầu ra lỗi:
example.coffee:4 exports.testSomething = (test) -> ^
module.js:296 throw err; ^SyntaxError: Unexpected token > at Module._compile (module.js:397:25) at Object..js (module.js:408:10) at Module.load (module.js:334:31) at Function._load (module.js:293:12) at require (module.js:346:19) at /usr/local/lib/node/nodeunit/lib/nodeunit.js:75:37 at /usr/local/lib/node/nodeunit/deps/async.js:508:13 at /usr/local/lib/node/nodeunit/deps/async.js:118:13 at /usr/local/lib/node/nodeunit/deps/async.js:134:9 at /usr/local/lib/node/nodeunit/deps/async.js:507:9
bất cứ ai có thể giúp tôi chỉ nhận được một đơn giản kiểm tra và chạy trong Coffeescript bằng Node.js?
Cảm ơn trước
Công việc thám tử hiện tượng. $ NODE_PATH của tôi trống, nhưng không có mô-đun nào khác của tôi được chăm sóc. Cảm ơn nhiều. –
@ user1028416 Bạn nên đánh dấu câu trả lời của mình là chính xác, sau đó. Trong khi bạn đang ở đó, hãy xem xét đưa ra câu trả lời +1. Chúng tôi làm việc cho cred trên Stack Overflow. :) –