运行node.js mochatesting时意外的令牌ILLEGAL

我已经搜遍了,但还没有弄清楚我做错了什么。 我正在尝试设置mocha来testingnode.js javascript应用程序文件。 我已经安装了节点,并已成功运行基本的东西,以确认它正在工作。

我在我的项目文件中安装了摩卡,在我的项目文件中也有一个名为“test”的Makefile和一个文件。

这是当我运行命令“make test”时,我的terminal(osx 10)吐出的错误。

humbleMousesMBP:chapter02 humbleMouse$ make test /Users/humbleMouse/chapter02/test/exchange.test.js:22  ^ SyntaxError: Unexpected token ILLEGAL at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at /Users/humbleMouse/chapter02/node_modules/mocha/bin/_mocha:313:27 at Array.forEach (native) at load (/Users/humbleMouse/chapter02/node_modules/mocha/bin/_mocha:310:9) at Object.<anonymous> (/Users/humbleMouse/chapter02/node_modules/mocha /bin/_mocha:301:1) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3 make: *** [test] Error 8 

这是我试图运行的testing:

 'use strict'; var assert = require('assert') , should = require('should'); var exchangeData = {}; suite('exchange', function() { test('buy should add a BUY nockmarket order', function(done) { exchangeData = exchange.buy(40, 100, exchangeData); exchangeData.buys.volumes[40].should.eql(100); done(); }); test('sell should add a SELL nockmarket order', function(done) { exchangeData = exchange.sell(41, 200, exchangeData); exchangeData.sells.volumes['41'].should.eql(200); //this is line 22 done(); });  test('sell should produce trades', function(done) { exchangeData = exchange.sell(40, 75, exchangeData); exchangeData.trades[0].price.should.eql(40); exchangeData.trades[0].volume.should.eql(75); exchangeData.buys.volumes[40].should.eql(25); exchangeData.sells.volumes[41].should.eql(200); done(); }); }); 

你的代码中有一些无效的字符,如果你使用了正确的文本编辑器,你会看到它们。 行号是有点偏离,但这显然是原因。

以下是Sublime Text的截图:

在这里输入图像描述

这是\uFFFC ,更多信息在这里 。

只要删除它们(它们不能被看到,所以从分号到下一个test( )都要删除。