meanjs / generator-meanjs

MEAN.JS Official Yeoman Generator
http://meanjs.org/
473 stars 177 forks source link

CRUD Module Server Test Templates over specify the resolution method. #254

Open mringer opened 7 years ago

mringer commented 7 years ago

Running tests on a generated CRUD module, I noticed multiple errors from MochaJS regarding Resolution Method Over Specification. It looks like the server template code is both returning a promise as well as calling .done() which aggravates Mocha.

https://github.com/mochajs/mocha/issues/2407

mleanos commented 7 years ago

@matthewringer Can you provide a link to the specific line in this project that are causing this issue?

How can I reproduce?

mringer commented 7 years ago

The steps to reproduce:

Starting from a cloned instance of MeanJS with NPM dependencies installed.

  1. Create a new CRUD module in my case "service" via the yo generator. $ yo meanjs:crud-module service
  2. Run server tests: $ npm run test:server

Tests for the new module fail with:

1) Service Model Unit Tests: Method Save should be able to save without problems: Error: Resolution method is overspecified. Specify a callback or return a Promise; not both. at modules/services/tests/server/service.server.model.tests.js:47:9 at node_modules/mongoose/lib/model.js:3327:16 at node_modules/mongoose/lib/document.js:1927:18

2) Service Model Unit Tests: Method Save should be able to show an error when try to save without name: Error: Resolution method is overspecified. Specify a callback or return a Promise; not both. at modules/services/tests/server/service.server.model.tests.js:56:9 at node_modules/mongoose/lib/model.js:3327:16 at node_modules/mongoose/lib/document.js:1932:15

I created a PR which removes the offending promise returns.

https://github.com/meanjs/generator-meanjs/pull/255