https://github.com/boundstate/sequelize-test-setup
Tool for setting up a test database and loading fixtures with Sequelize
https://github.com/boundstate/sequelize-test-setup
Last synced: about 1 year ago
JSON representation
Tool for setting up a test database and loading fixtures with Sequelize
- Host: GitHub
- URL: https://github.com/boundstate/sequelize-test-setup
- Owner: boundstate
- Created: 2015-08-12T17:02:57.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-05-07T19:06:08.000Z (about 7 years ago)
- Last Synced: 2024-10-14T01:03:20.437Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Sequelize Test Setup
Tool for setting up a test database and loading fixtures with [Sequelize].
It runs migrations and destroys all models before loading the fixtures via [sequelize-fixtures].
## Install
```sh
npm install sequelize-test-setup
```
## Usage
```sh
var sequelizeTestSetup = require('sequelize-test-setup');
var models = require('./models');
sequelizeTestSetup({
sequelize: models.sequelize,
models: models,
migrationsPath: 'migrations',
fixtures: ['fixtures/test_data.json']
});
```
## Options
- `sequelize` *Sequelize* - Sequelize instance
- `models` *Array* - Sequelize models
- `migrationsPath` *String* - path to migrations
- `fixtures` *Array* - fixture filenames to load via [sequelize-fixtures]
- `truncate` *Boolean* - use TRUNCATE instead of DELETE queries (default: `true`)
## Tips
MySQL does not support using TRUNCATE TABLE for an InnoDB table if there are any FOREIGN KEY constraints. If you get `ER_TRUNCATE_ILLEGAL_FK` errors you should set `truncate` to `false` to use DELETE queries instead.
[Sequelize]: http://sequelizejs.com
[sequelize-fixtures]: https://github.com/domasx2/sequelize-fixtures