Hello,
I'm currently using mocha v2.3.4, chai, and es6 with babel 6 and running in node v5.3.0.
This is my test script that I run with npm:
mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive
I have mocha globally installed, but whenever I run the test script I get the following output in my terminal:
ReferenceError: describe is not defined
Does anyone have any Ideas for why this may be happening?
I don't know _why_ this is happening, but see this SO question
this may be a mocha bug, or maybe you just can't do this anymore with babel 6, I dunno. someone should find out!
@boneskull thanks for the feedback but unfortunately I already have my .babelrc configured. Hopefully it isn't a big problem because I have to deliver the project I'm working on in the next few days.
@kennetpostigo then skip that step?
@boneskull I'm in charge of testing 馃槄
@kennetpostigo I have no idea what you're talking about.
@boneskull what did you mean by "then skip that step?"
@kennetpostigo
"unfortunately I already have my .babelrc configured"
then, as in the SO answer, skip creating .babelrc.
I would like to open the same issue again. I'm upgrading an existing node project to Typescript. I'm receiving the same error when trying to run mocha for the following project specs:
I have all the @types needed installed (mocha, chai, node, supertest, etc) and adding the @types directory to the typeRoots of the TS compiler options in .tsconfig.json. This way I don't have to do import "mocha" at the beginning of my test
I have also installed ts-babel-node which sits on top of ts-node to transpile ES6 to ES5 in Node Typescript projects. This is working fine, however, it's unable to recognize describe during runtime only. The compiler is referencing the @types/mocha 's describe() definition but not when I run the tests.
.babelrc is defined too
Running the main app with ts-babel-node src/server.ts runs fine
Running tests with mocha -r ts-babel-node/bin/ts-babel-node test/test.ts fails in reading the describe() method.
I also tried running mocha --compilers js:ts-babel-node/bin/ts-babel-node test/test.ts
but with no luck.
Any tips would be appreciated
mocha is a wrapper around node. _mocha is the "real" executable. try ts-babel-node _mocha <mocha options>
Most helpful comment
I would like to open the same issue again. I'm upgrading an existing node project to Typescript. I'm receiving the same error when trying to run mocha for the following project specs:
I have all the
@typesneeded installed (mocha, chai, node, supertest, etc) and adding the@typesdirectory to thetypeRootsof the TS compiler options in.tsconfig.json. This way I don't have to doimport "mocha"at the beginning of my testI have also installed
ts-babel-nodewhich sits on top ofts-nodeto transpile ES6 to ES5 in Node Typescript projects. This is working fine, however, it's unable to recognizedescribeduring runtime only. The compiler is referencing the@types/mocha'sdescribe()definition but not when I run the tests..babelrcis defined tooRunning the main app with
ts-babel-node src/server.tsruns fineRunning tests with
mocha -r ts-babel-node/bin/ts-babel-node test/test.tsfails in reading thedescribe()method.I also tried running
mocha --compilers js:ts-babel-node/bin/ts-babel-node test/test.tsbut with no luck.
Any tips would be appreciated