rochejul / sequelize-mocking

Sequelize extension to deal with data-mocking for testing
MIT License
63 stars 26 forks source link

Bug occurred about setting a custom timezone is not supported #35

Open BaeJi77 opened 4 years ago

BaeJi77 commented 4 years ago

I use sequelize version 5.19.2. and use mysql. and set-up like below code. There is in test file

const Database = require('../../models').sequelize;
    sequelizeMockingMocha(
        Database,
        path.resolve(path.join(__dirname, '../fake-trainer-database.json')),
        {'logging': console.log}
    );

There is in model set-up file

let sequelize;
if (config.use_env_variable) {
  sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
  sequelize = new Sequelize(config.database, config.username, config.password, config);
}
...

db.sequelize = sequelize;
db.Sequelize = Sequelize;

db.Trainer = require('./trainer')(sequelize, Sequelize);

I don't know why this error happened. Are there error in my code? plz help me.

Error: Setting a custom timezone is not supported by SQLite, dates are always returned as UTC. Please remove the custom timezone parameter.
    at new Sequelize (node_modules/sequelize/lib/sequelize.js:273:13)
    at Function.create (node_modules/sequelize-mocking/lib/sequelize-mocking.js:95:31)
    at createAndLoadFixtureFile (node_modules/sequelize-mocking/lib/sequelize-mocking.js:123:14)
    at wrapper (node_modules/sequelize-mocking/node_modules/lodash/lodash.js:5193:19)
    at Context.<anonymous> (node_modules/sequelize-mocking/lib/sequelize-mocking-mocha.js:33:13)
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:126:23)

TypeError: Cannot read property '__originalSequelize' of null
    at Function.unhookNewModel (node_modules/sequelize-mocking/lib/sequelize-mocking.js:277:29)
    at Function.restore (node_modules/sequelize-mocking/lib/sequelize-mocking.js:249:26)
    at Context.<anonymous> (node_modules/sequelize-mocking/lib/sequelize-mocking-mocha.js:43:18)
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:126:23)
rochejul commented 4 years ago

Hi @BaeJi77 Could you provide a tiny zip with a sample to illustrate your issue? What is the provided "config" object? Here a thread around timezone and sequelize: https://github.com/sequelize/sequelize/issues/854 Regards

w4sevens commented 2 years ago

i met the same question, and the error tips like this ------------Setting a custom timezone is not supported by SQLite, dates are always returned as UTC. Please remove the custom timezone parameter-------- need help ?