I have a Typescript class that is getting quite big. To organize it better and avoid cramming it up, I'd like to split it over 5-7 different files based on the page object structure. Currently it looks like this in a single file:
mainAPI.ts
const axios = require('axios');
export class API {
makeAxiosRequest() {}
doLogin() {}
getJSESSIONID() {}
getLoginResponse() {}
deleteAnUser(userName) {}
addAnUser(userName) {}
.,etc
}
testFile.ts
import mainAPI from mainAPI.ts
await mainAPI.doLogin();
await mainAPI.addAnUser();
await mainAPI.logout();
EDIT: I'm looking to achieve something like this:
mainAPI.ts
const axios = require('axios');
export class API {
//Want the methods from loginAPI.ts, userAPI.ts, purchaseAPI.ts to be a part of this class.
}
loginAPI.ts
doLogin() {}
doAdminLogin() {}
doMemberLogin() {} etc
userAPI.ts
deleteAnUser() {}
addAnUser() {}
updateUser() {} etc
purchaseAPI.ts
addToCart() {}
buyProduct() {}
cancelOrder() {} etc
So far I have only tried to split the API methods component-wise by comments. I'm reaching out for help on how one can split a class into multiple files. Thank you