bredikhin / sailsjs-mocha-testing-barrels-fixtures-example

An example of Sails.js-project testing with Mocha and Barrels for fixtures
121 stars 22 forks source link

npm test command fails #3

Closed carpiediem closed 9 years ago

carpiediem commented 9 years ago

I'm new to node.js, so forgive me if this is my own mistake. I copied the project and ran "npm install". At that point, "sails lift" was working perfectly, but "npm test" resulted in an error. Running "mocha" (not in your directions, I know) told me that there were 0 tests. I'm using Git Bash as Administrator on Windows 8.1, if that matters.

$ npm test
> sailsjs-mocha-testing-barrels-fixtures-example@0.10.1 test d:\nodejs\appleorange
> PORT=9999 NODE_ENV=test mocha -R spec -b --recursive

'PORT' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

Is this a bug or did I miss some step? (d:\nodejs\appleorange is where I copied the project and ran the commands from)

bredikhin commented 9 years ago

Yeah, running Node packages/apps on Windows is... hmm, let's say, tricky. Apparently, Git Bash doesn't support environment variables. What you can try is running mocha directly (sort of like you tried) by stripping those variables: something like mocha -R spec -b --recursive. If it complains about zero tests, try to mention test folder as parameter, or a specific test file.

carpiediem commented 9 years ago

Thanks, your suggestion did seem to help. However, I'm still getting a timeout error. Do you think that means that the before function is not succeeding at lifting the app?

 $ mocha -R spec -b --recursive

  1) "before all" hook

  0 passing (5s)
  1 failing

  1)  "before all" hook:
     Error: timeout of 5000ms exceeded
      at done (c:\Users\Ryan\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:205:67)
      at c:\Users\Ryan\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:226:9
      at d:\nodejs\appleorange\test\bootstrap.test.js:28:7
      at done (d:\nodejs\appleorange\node_modules\barrels\node_modules\async\lib\async.js:135:19)
      at d:\nodejs\appleorange\node_modules\barrels\node_modules\async\lib\async.js:32:16
      at done (d:\nodejs\appleorange\node_modules\barrels\node_modules\async\lib\async.js:135:19)
      at d:\nodejs\appleorange\node_modules\barrels\node_modules\async\lib\async.js:32:16
      at Object.async.each (d:\nodejs\appleorange\node_modules\barrels\node_modules\async\lib\async.js:121:20)
      at d:\nodejs\appleorange\node_modules\barrels\index.js:76:17
      at bound (d:\nodejs\appleorange\node_modules\sails\node_modules\lodash\dist\lodash.js:957:21)
      at applyInOriginalCtx (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:416:80)
      at wrappedCallback (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:315:18)
      at _normalizeCallback.callback.success (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\node-switchback\lib\normalize.js:33:31)
      at _switch (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\node-switchback\lib\factory.js:35:28)
      at returnResults (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\basic.js:168:9)
      at d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\basic.js:74:16
      at d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:82:7
      at Object.async.each (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\async\lib\async.js:121:20)
      at d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:425:11
      at d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:564:5
      at Object.async.each (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\async\lib\async.js:121:20)
      at _buildChildOpts (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:453:9)
      at _execChildOpts (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:421:8)
      at d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:80:10
      at bound (d:\nodejs\appleorange\node_modules\sails\node_modules\lodash\dist\lodash.js:957:21)
      at applyInOriginalCtx (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:416:80)
      at wrappedCallback (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:315:18)
      at _normalizeCallback.callback.success (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\node-switchback\lib\normalize.js:33:31)
      at _switch (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\node-switchback\lib\factory.js:35:28)
      at d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\adapter\dql.js:165:7
      at bound (d:\nodejs\appleorange\node_modules\sails\node_modules\lodash\dist\lodash.js:957:21)
      at applyInOriginalCtx (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:416:80)
      at wrappedCallback (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:315:18)
      at _normalizeCallback.callback.success (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\node-switchback\lib\normalize.js:33:31)
      at _switch (d:\nodejs\appleorange\node_modules\sails\node_modules\waterline\node_modules\node-switchback\lib\factory.js:35:28)
      at null._onTimeout (d:\nodejs\appleorange\node_modules\sails-memory\lib\database.js:218:5)
      at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

bootstrap.test.js:28:7 refers to the barrels.populate() function.

    barrels.populate(function(err) {
      done(err, sails);
    });
bredikhin commented 9 years ago

Some things you can try:

    barrels.populate(function(err) {
      done(err, sails);
    }, false);
carpiediem commented 9 years ago

That did the trick. Thanks for your help!