I have a few chai tests that call functions that should get a result back from my mock db tables, I'm trying to mock my SQL db using sequalize-mock so the tests won't fall over. I'm trying to add seed data to the mockDb so the tests can work with them, however, I keep getting this weird error:
SequelizeMockEmptyQueryQueueError: No query results are queued. Unexpected query attempted to be run
Any ideas why this happens?
Here is my mock db init which is running before each test.
This is glboally available in SQL Mock file
const SequelizeMock = require("sequelize-mock");
const dbMock = new SequelizeMock({});
export const initializeMockDatabase = async () => {
const GlobalParam = await generateSqlSchema(
dbMock,
GLOBAL_PARAMS_SCHEMA,
);
const globalParamsfilePath = path.resolve(
__dirname,
"../mocks/global_params.json",
);
const globalParamsData = fs.readFileSync(globalParamsfilePath, "utf8");
const globalParams = JSON.parse(globalParamsData);
// Loop through the globalParams object and create records
for (const key of Object.keys(globalParams)) {
const globalParam = GlobalParam.build({
name: key,
value: globalParams[key as keyof typeof globalParams],
});
await globalParam.save();
}
};
I have a few chai tests that call functions that should get a result back from my mock db tables, I'm trying to mock my SQL db using
sequalize-mock
so the tests won't fall over. I'm trying to add seed data to the mockDb so the tests can work with them, however, I keep getting this weird error:SequelizeMockEmptyQueryQueueError: No query results are queued. Unexpected query attempted to be run
Any ideas why this happens?
Here is my mock db init which is running before each test.
This is glboally available in SQL Mock file
And then in the before:
And executing queries like:
Any ideas? What I'm missing?