0

I have a very simple code structure like this

TestWorks.ts

const axios = require('axios');

export class TestWorks{

    async getUsersList(param1:TestModel, userDetail:any){

    console.log("BEGIN -- ... ");

And then this is my test class

MyTest.ts

const testworks = require("../src/interfaces/TestService/TestWorks");

it('Get Users', async () => {
    var x = await testworks.getUsersList({}, {});
    expect(x).to.be.an("object");
});

but I am seeing the following error, unable to figure out what the issue could be. The paths are definitely right, not an issue with the file paths of where the files are

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

1 Answer 1

1

testworks refers to the module (or whatever TypeScript exports) because you use require(). You should use import for TypeScript modules.

import { TestWorks } from '../src/interfaces/TestService/TestWorks';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.