Makefile -内容:
REPORTER = dot
all: build
build:
@./node_modules/coffee-script/bin/coffee \
-c \
-o lib src
clean:
rm -rf lib
mkdir lib
watch:
@./node_modules/coffee-script/bin/coffee \
-o lib \
-cw src
test:
@./node_modules/mocha/bin/mocha \
--reporter $(REPORTER) \
test/*.coffee
.PHONY: build clean watch test
项目根目录有一个测试文件夹,其中包含两个文件: mocha.opts和example.coffee
example.coffee -内容
describe "feature", ->
it "should add two numbers", ->
(2+2).should.equal 4
运行make test
时,出现以下错误:
cribe 'feature',
^^^^^^^^^
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected string
at Module._compile (module.js:429:25)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at /home/my_username/testcode/coffeepress/node_modules/mocha/bin/_mocha:261:27
at Array.forEach (native)
at load (/home/my_username/testcode/coffeepress/node_modules/mocha/bin/_mocha:258:9)
at Object.<anonymous> (/home/my_username/testcode/coffeepress/node_modules/mocha/bin/_mocha:249:1)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
使用js文件运行Mocha成功,但无法使用CoffeeScript运行它。我真的很想--为了代码简洁。
请指点一下。
发布于 2014-01-30 08:10:58
发布于 2020-04-27 14:16:22
对于mocha的最新更新,要求语句必须在package.json文件中编写为
"mocha":{
"require":"coffeescript",
"reporter":"spec"
},
发布于 2014-04-23 23:22:47
我需要对我的mocha args进行两次更改才能使其正常工作:
--require coffee-script/register
--compilers coffee:coffee-script/register
https://stackoverflow.com/questions/9940838
复制相似问题