OverwriteModelError and Mocha watch on generated models
ericjeker opened this issue · comments
Steps to reproduce
- Create an app with the CLI and select Mocha + assert
feathers g app
? Project name new-test-app
? Description
? What folder should the source files live in? src
? Which package manager are you using (has to be installed globally)? npm
? What type of API are you making? (Press to select, to toggle all, to invert selection)REST, Realtime via Socket.io
? Which testing framework do you prefer? Mocha + assert
- Create a service with Mongoose
feathers g service
? What kind of service is it? Mongoose
? What is the name of the service? test
? Which path should the service be registered on? /test
? What is the database connection string? mongodb://localhost:27017/new_test_app
- Run mocha with -w parameter
./node_modules/.bin/mocha test/ -w
- Do a modification in your code
OverwriteModelError: Cannot overwrite
test
model once compiled.
Expected behavior
We should not have an exception in that case. That is due to the way models are generated by CLI.
The error is described here: Automattic/mongoose#1251
Wrapping the model creation in a try catch solves the issue.
Actual behavior
OverwriteModelError: Cannot overwrite
test
model once compiled.
System configuration
Module versions (especially the part that's not working):
Feathers CLI 3.9.0
NodeJS version:
v10.14.2
Operating System:
Any
Browser Version:
N/A
React Native Version:
N/A
Module Loader:
N/A
Thanks for this <3