MCPcopy Index your code
hub / github.com/BlinkUX/sequelize-mock

github.com/BlinkUX/sequelize-mock @v0.10.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.10.2 ↗ · + Follow
23 symbols 28 edges 17 files 8 documented · 35%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Sequelize Mock

npm CircleCI Coveralls MIT License Documentation Status

A mocking interface designed for testing code that uses Sequelize.

Documentation at sequelize-mock.readthedocs.io

Install

npm i sequelize-mock --save-dev

Getting Started

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');

Initialize the library as you would Sequelize

var DBConnectionMock = new SequelizeMock();

Define your models

var UserMock = DBConnectionMock.define('users', {
        'email': 'email@example.com',
        'username': 'blink',
        '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
});

Contributing

This library is under active development, so you should feel free to submit issues, questions, or pull requests.

License

Created by Blink UX and licensed under the MIT license. Check the LICENSE file for more information.

Core symbols most depended-on inside this repo

linkText
called by 2
scripts/doc-gen.js
resultsQueueHandler
called by 1
src/queryinterface.js
propagationHandler
called by 1
src/queryinterface.js
fallbackHandler
called by 1
src/queryinterface.js
processHandler
called by 1
src/queryinterface.js
Sequelize
called by 0
src/sequelize.js
fakeModel
called by 0
src/model.js
noop
called by 0
src/model.js

Shape

Function 23

Languages

TypeScript100%

Modules by API surface

src/queryinterface.js5 symbols
test/sequelize.spec.js4 symbols
test/model.spec.js3 symbols
scripts/doc-gen.js3 symbols
test/queryinterface.spec.js2 symbols
src/model.js2 symbols
src/data-types.js2 symbols
src/sequelize.js1 symbols
src/instance.js1 symbols

For agents

$ claude mcp add sequelize-mock \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page