Jestjs 如何正确地使用Jest文件?(使用模块模式js文件)

Jestjs 如何正确地使用Jest文件?(使用模块模式js文件),jestjs,require,Jestjs,Require,可能是个愚蠢的问题 我开始使用JEST进行测试 我有我的js应用程序: var app={ init:function{ //some code}, ... } module.exports = app; 和我的app.test.js: const {app} = require('../js/index.js') test('type of variable', () => { expect(typeof app.someFunction(app.someVar)).toBe("

可能是个愚蠢的问题

我开始使用JEST进行测试

我有我的js应用程序:

var app={ init:function{ //some code}, ... }
module.exports = app;
和我的app.test.js:

const {app} = require('../js/index.js')

test('type of variable', () => {
  expect(typeof app.someFunction(app.someVar)).toBe("'number");
});
我有一个典型的错误:

TypeError: Cannot read property 'someFunction' of undefined
这似乎很愚蠢,但我从来没有清楚地了解这些要求在客户端。。。 它与Jest getStarted示例完美结合

我的阿尔博是

-js
----index.js
-tests
----app.text.js
上面的行返回对象{},并且您正试图从销毁行var{app}中的对象中选取app

删除{}

const app=require'../js/index.js' 测试“变量类型”,=>{ expecttypeof app.someFunctionapp.someVar.toBe'number;
};完美的谢谢你的欢迎,很乐意帮忙。如果对您有效,请接受:
module.exports = app