Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Mocha、Chai、node.js测试异步方法_Node.js_Unit Testing_Mocha.js_Chai - Fatal编程技术网

使用Mocha、Chai、node.js测试异步方法

使用Mocha、Chai、node.js测试异步方法,node.js,unit-testing,mocha.js,chai,Node.js,Unit Testing,Mocha.js,Chai,我有这样一个非常简单的代码结构 TestWorks.ts 这是我的测试课 MyTest.ts 但我看到以下错误,无法找出问题所在。路径绝对正确,而不是文件所在位置的文件路径问题 Get Users: TypeError: testworks.getUsersList is not a function at C:\Users\xxxxxx\Documents\xxxxx\test\test-server.test.ts:53:28 testworks引用模块(或任何类型脚本

我有这样一个非常简单的代码结构

TestWorks.ts 这是我的测试课

MyTest.ts 但我看到以下错误,无法找出问题所在。路径绝对正确,而不是文件所在位置的文件路径问题

Get Users:
     TypeError: testworks.getUsersList is not a function
     at C:\Users\xxxxxx\Documents\xxxxx\test\test-server.test.ts:53:28

testworks
引用模块(或任何类型脚本导出),因为您使用
require()
。对于TypeScript模块,应该使用
import

import { TestWorks } from '../src/interfaces/TestService/TestWorks';
Get Users:
     TypeError: testworks.getUsersList is not a function
     at C:\Users\xxxxxx\Documents\xxxxx\test\test-server.test.ts:53:28
import { TestWorks } from '../src/interfaces/TestService/TestWorks';