sequelize-test-helpers | A collection of utilities to help | Unit Testing library
kandi X-RAY | sequelize-test-helpers Summary
kandi X-RAY | sequelize-test-helpers Summary
A collection of utilities to help with unit-testing Sequelize models and code that needs those models.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Numeric type
- Create a new null .
- String type .
sequelize-test-helpers Key Features
sequelize-test-helpers Examples and Code Snippets
Community Discussions
Trending Discussions on sequelize-test-helpers
QUESTION
I am using sequelize-test-helpers
which provides a mock sequelize connection made of sinon
spies and stubs. I have three files as follows:
ANSWER
Answered 2020-Jun-08 at 20:15The declaration of User inside function User
in models.js
should be const User = //definition
. Otherwise, it creates a scoping issue which causes the function itself to be returned at the end. This makes the User model a singleton.
When the require from another file (integration test) modifies what it think is its own version of the user model, it actually modifies the user model that the unittest.js file holds as well. This was a good lesson for myself to be extra careful when reusing variable names, or avoid them altogether.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sequelize-test-helpers
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page