admin管理员组文章数量:1336193
I am running some unit tests after a node version upgrade and jest version upgrade in package.json. It is erroring out with
TypeError: Cannot read properties of undefined (reading '_setAdapter')
The unit test attempts to mock a knex config.
import { mock as mockKnex, getTracker } from "mock-knex";
import { postgresConnectionPool } from "../../src/database/PostgresConnectionPool";
mockKnex(postgresConnectionPool); // This line is erroring out
describe("Test Suites", () => {
// test cases
})
However this is erroring out because a new object of mockKnex is not created. The error is TypeError: Cannot read properties of undefined (reading '_setAdapter')
// This code is from mock-knex public library
value: function mock(db) {
this._setAdapter(db); // It is failing on this line because the this object is undefined
return this._adapter.mock(db);
}
One of my questions is why is this happening ? Is it a jest issue or node issue ?
My Jest Config
module.exports = {
moduleFileExtensions: ["ts", "js"],
transform: {
".(ts)": "ts-jest",
},
testMatch: ["**/test/**/*.test.(ts|js)"],
testEnvironment: "node",
setupFiles: [
"<rootDir>/test/jestSetup.js", // mock required environment variables
],
};
本文标签: javascriptJest unit tests are failing after jest upgrade to 2970 from 2706Stack Overflow
版权声明:本文标题:javascript - Jest unit tests are failing after jest upgrade to 29.7.0 from 27.0.6 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742401836a2468038.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论