nest icon indicating copy to clipboard operation
nest copied to clipboard

[V5] `npm run test` failed after new project created by nest-cli

Open janckerchen opened this issue 8 years ago • 5 comments

Setting up a new project with Nest CLI, nothing changed, npm test failed

$ nest new hume2
$ cd hume2
$ npm run test

> [email protected] test /opt/dev/hume2
> jest

 FAIL  src/app.controller.spec.ts
  AppController
    root
      ✕ should return "Hello World!" (138ms)

  ● AppController › root › should return "Hello World!"

    Nest can't resolve dependencies of the AppController (?). Please verify whether [0] argument is available in the current context.

      at Injector.<anonymous> (../node_modules/@nestjs/core/injector/injector.js:156:23)
          at Generator.next (<anonymous>)
      at fulfilled (../node_modules/@nestjs/core/injector/injector.js:4:58)
          at <anonymous>
      at process._tickCallback (../internal/process/next_tick.js:118:7)

  ● AppController › root › should return "Hello World!"

    TypeError: Cannot read property 'get' of undefined

      at Object.it (app.controller.spec.ts:16:33)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (../internal/process/next_tick.js:118:7)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        3.532s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jason/.npm/_logs/2018-04-28T06_10_02_033Z-debug.log

janckerchen avatar Apr 28 '18 06:04 janckerchen

Same issue for me. Just added AppService and now runs as it should.

screen shot 2018-04-28 at 11 12 10

ruisaraiva19 avatar Apr 28 '18 10:04 ruisaraiva19

cc @ThomRick The ts starter is fixed already. This issue should be fixed in the next CLI release.

kamilmysliwiec avatar Apr 29 '18 14:04 kamilmysliwiec

@kamilmysliwiec I'm on it ;-)

thomrick avatar Apr 29 '18 14:04 thomrick

Should be ok with the CLI 5.1.1

thomrick avatar Apr 30 '18 09:04 thomrick

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Sep 25 '19 01:09 lock[bot]