0

Trying to test mongoose: https://github.com/Automattic/mongoose

When I changed version of node the npm.cmd "run-script" "test" does not work and gives me the message:

C:\2016\IT\nb\M11\22\mongoose\test\connection.test.js:145
var repl2 = repl1.replace('mongodb://', '').split(',');
                 ^

This is what I get:

"C:\Program Files\nodejs\npm.cmd" "run-script" "test"

> mongoose@4.6.9-pre test C:\2016\IT\nb\M11\21\mongoose
> mocha test/*.test.js test/**/*.test.js

C:\2016\IT\nb\M11\21\mongoose\test\connection.test.js:145
    var repl2 = repl1.replace('mongodb://', '').split(',');
                 ^

TypeError: Cannot read property 'replace' of undefined
    at Suite.<anonymous> (C:\2016\IT\nb\M11\21\mongoose       \test\connection.test.js:145:22)
    at Object.create (C:\2016\IT\nb\M11\21\mongoose\node_modules\mocha\lib\interfaces\common.js:114:19)
    at context.describe.context.context (C:\2016\IT\nb\M11\21\mongoose\node_modules\mocha\lib\interfaces\bdd.js:44:27)
    at Suite.<anonymous> (C:\2016\IT\nb\M11\21\mongoose\test\connection.test.js:136:3)
    at Object.create (C:\2016\IT\nb\M11\21\mongoose\node_modules\mocha\lib\interfaces\common.js:114:19)
    at context.describe.context.context (C:\2016\IT\nb\M11\21\mongoose\node_modules\mocha\lib\interfaces\bdd.js:44:27)
    at Object.<anonymous> (C:\2016\IT\nb\M11\21\mongoose\test\connection.test.js:16:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at C:\2016\IT\nb\M11\21\mongoose\node_modules\mocha\lib\mocha.js:222:27
    at Array.forEach (native)

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Mircea\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "test"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! mongoose@4.6.9-pre test: `mocha test/*.test.js test/**/*.test.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mongoose@4.6.9-pre test script 'mocha test/*.test.js test/**/*.test.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mongoose package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mocha test/*.test.js test/**/*.test.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs mongoose
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls mongoose
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\2016\IT\nb\M11\21\mongoose\npm-debug.log
Done.

TypeError: Cannot read property 'replace' of undefined

Before installing node-v6.9.1

"C:\Program Files\nodejs\npm.cmd" "run-script" "test"

> mongoose@4.6.9-pre test C:\2016\IT\nb\M11\21\mongoose
> mocha test/*.test.js test/**/*.test.js

Not testing multi-mongos support

 You're not testing shards! 
 Please set the MONGOOSE_SHARD_TEST_URI env variable. 
 e.g: `mongodb://localhost:27017/database 
 Sharding must already be enabled on your database 


(node:11752) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ..... 
 You're not testing replica sets! 
 Please set the MONGOOSE_SET_TEST_URI env variable. 
 e.g: `mongodb://localhost:27017/db,localhost…` 

.................................!.................
(node:11752) DeprecationWarning: Mongoose: Query.prototype.stream() is deprecated in mongoose >= 4.5.0, use Query.prototype.cursor() instead
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  !.......................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  ........................................................
  .............................

  1651 passing (2m)
  2 failing

  1) model create() creates in parallel:
     Error: timeout of 1000ms exceeded. Ensure the done() callback is being called in this test.


  2) query stream: pipe:
     Uncaught Error: ENOENT: no such file or directory, open 'C:\tmp\_mongoose_stream_out.txt'




Done.

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Mircea\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "test"
npm ERR! node v7.1.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! mongoose@4.6.9-pre test: `mocha test/*.test.js test/**/*.test.js`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the mongoose@4.6.9-pre test script 'mocha test/*.test.js test/**/*.test.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mongoose package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mocha test/*.test.js test/**/*.test.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs mongoose
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls mongoose
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\2016\IT\nb\M11\21\mongoose\npm-debug.log

I was able to run the test after I dropped database using Robomongo.

I get: 1652 passing (3m) 3 failing

Jack Bonneman
  • 1,821
  • 18
  • 24
MToma
  • 549
  • 1
  • 5
  • 9

1 Answers1

0

Line 144 of connection code defines repl1 as process.env.MONGOOSE_SHARD_TEST_URI meaning the environmental variable isn't set. It needs to be set to the uri for the mongo shard being tested.

It looks like your in windows, and you can do that by setting the environmental variables to provide Node with the information it needs to run for the selected environment. MONGOOSE_SHARD_TEST_URI=yourURI node connection.test.js - See more here

Community
  • 1
  • 1
Steven Lacks
  • 869
  • 6
  • 13
  • I had that environment and before to install node-v6.9.1 it ask me to set MONGOOSE_SHARD_TEST_URI; I did and it works I think. – MToma Nov 23 '16 at 15:25
  • I was able to run test after I dropped database using Robomongo I get: 1652 passing (3m) 3 failing – MToma Nov 25 '16 at 15:48