
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
sequelize-mock-v5
Advanced tools
A simple mock interface specifically for testing code relying on Sequelize models
A mocking interface designed for testing code that uses Sequelize.
npm i sequelize-mock-v5 --save-dev
The Mock Models created with this library function as drop in replacements for your unit testing.
Start by importing the library
var SequelizeMock = require('sequelize-mock-v5');
Initialize the library as you would Sequelize
var DBConnectionMock = new SequelizeMock();
Define your models
var UserMock = DBConnectionMock.define('users', {
'email': 'email@example.com',
'username': 'foyer',
'picture': 'user-picture.jpg',
}, {
instanceMethods: {
myTestFunc: function () {
return 'Test User';
},
},
});
Once Mock models have been defined, you can use them as drop-in replacements for your Sequelize model objects. Data is not retrieved from a database and instead is returned based on the setup of the mock objects, the query being made, and other applied or included information.
For example, your code might look something like this
UserMock.findOne({
where: {
username: 'my-user',
},
}).then(function (user) {
// `user` is a Sequelize Model-like object
user.get('id'); // Auto-Incrementing ID available on all Models
user.get('email'); // 'email@example.com'; Pulled from default values
user.get('username'); // 'my-user'; Pulled from the `where` in the query
user.myTestFunc(); // Will return 'Test User' as defined above
});
This library is under active development, so you should feel free to submit issues, questions, or pull requests.
Created by Blink UX and licensed under the MIT license. Check the LICENSE file for more information.
FAQs
A simple mock interface specifically for testing code relying on Sequelize models
We found that sequelize-mock-v5 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.