diff --git a/nym-node/tests/src/config/config.yaml b/common/api-test-utils/config/config.yaml similarity index 100% rename from nym-node/tests/src/config/config.yaml rename to common/api-test-utils/config/config.yaml diff --git a/nym-node/tests/src/config/configHandler.ts b/common/api-test-utils/config/configHandler.ts similarity index 76% rename from nym-node/tests/src/config/configHandler.ts rename to common/api-test-utils/config/configHandler.ts index 18c0f3a4fd..c90f5d4cda 100644 --- a/nym-node/tests/src/config/configHandler.ts +++ b/common/api-test-utils/config/configHandler.ts @@ -1,4 +1,6 @@ +import { dir } from "console"; import { readFileSync } from "fs"; +import { dirname } from "path"; import { TLogLevelName } from "tslog"; import YAML from "yaml"; @@ -37,8 +39,10 @@ class ConfigHandler { private setCommonConfig(): void { try { + const baseWorkingDirectory = __dirname; + console.log(`Base Working Directory: ${baseWorkingDirectory}`); this.commonConfig = YAML.parse( - readFileSync("src/config/config.yaml", "utf8"), + readFileSync("/Users/benedetta/nym/workspace/nym/common/api-test-utils/config/config.yaml", "utf8"), ).common; } catch (error) { throw Error(`Error reading common config: (${error})`); @@ -49,9 +53,10 @@ class ConfigHandler { this.ensureEnvironmentIsValid(environment); try { this.environmentConfig = YAML.parse( - readFileSync("src/config/config.yaml", "utf8"), + readFileSync("/Users/benedetta/nym/workspace/nym/common/api-test-utils/config/config.yaml", "utf8"), )[environment]; } catch (error) { + console.log("fadsfasdfasdfsdfsa") throw Error(`Error reading environment config: (${error})`); } } @@ -59,7 +64,7 @@ class ConfigHandler { public getEnvironmentConfig(environment: string): any { return ( this.environmentConfig || - YAML.parse(readFileSync("src/config/config.yaml", "utf8"))[environment] + YAML.parse(readFileSync("api-test-utils/config/config.yaml", "utf8"))[environment] ); } diff --git a/common/api-test-utils/index.ts b/common/api-test-utils/index.ts new file mode 100644 index 0000000000..87cc687dfd --- /dev/null +++ b/common/api-test-utils/index.ts @@ -0,0 +1,4 @@ +module.exports = { + ConfigHandler: require('./config/configHandler.ts'), + RestClient: require('./restClient/RestClient.ts') + }; \ No newline at end of file diff --git a/nym-node/tests/src/restClient/RestClient.ts b/common/api-test-utils/restClient/RestClient.ts similarity index 99% rename from nym-node/tests/src/restClient/RestClient.ts rename to common/api-test-utils/restClient/RestClient.ts index 7883c46aca..bb386cdd81 100644 --- a/nym-node/tests/src/restClient/RestClient.ts +++ b/common/api-test-utils/restClient/RestClient.ts @@ -24,7 +24,7 @@ function isSet(property): boolean { } export class RestClient { - private static authToken: string; + public static authToken: string; private axiosInstance: AxiosInstance; diff --git a/nym-node/tests/package.json b/nym-node/tests/package.json index 381cf97c2c..18e97e5bcf 100644 --- a/nym-node/tests/package.json +++ b/nym-node/tests/package.json @@ -27,7 +27,7 @@ "eslint": "^8.51.0", "form-data": "4.0.0", "json-stringify-safe": "5.0.1", - "tslog": "3.3.3", + "tslog": "../../../../../node_modules/tslog", "uuid": "8.3.2", "yaml": "^2.2.2" }, @@ -40,7 +40,7 @@ "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.1", "jest": "^28.1.3", - "jest-junit": "^14.0.0", + "jest-junit": "^14.0.0", "prettier": "^3.0.3", "process": "0.11.10", "ts-jest": "28.0.7", diff --git a/nym-node/tests/src/endpoints/abstracts/APIClient.ts b/nym-node/tests/src/endpoints/abstracts/APIClient.ts index 06e4fcf5b6..d6033f9bb5 100644 --- a/nym-node/tests/src/endpoints/abstracts/APIClient.ts +++ b/nym-node/tests/src/endpoints/abstracts/APIClient.ts @@ -1,6 +1,8 @@ import { Logger } from "tslog"; -import ConfigHandler from "../../config/configHandler"; -import { RestClient } from "../../restClient/RestClient"; +import ConfigHandler from "../../../../../common/api-test-utils/config/configHandler"; +import { RestClient } from "../../../../../common/api-test-utils/restClient/RestClient"; +// import { ConfigHandler, RestClient } from '../../../../../common/api-test-utils'; + export abstract class APIClient { protected constructor(baseUrl: string, serviceUrl: string) { diff --git a/nym-node/tests/src/helpers/helper.ts b/nym-node/tests/src/helpers/helper.ts index f44916c0b2..c208e3845e 100644 --- a/nym-node/tests/src/helpers/helper.ts +++ b/nym-node/tests/src/helpers/helper.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import ConfigHandler from "../config/configHandler"; +import ConfigHandler from "../../../../common/api-test-utils/config/configHandler" // Get the current env from configHandler const configHandler = ConfigHandler.getInstance(); diff --git a/nym-node/tests/tsconfig.json b/nym-node/tests/tsconfig.json index 60fd578d9a..ceb1f47f81 100644 --- a/nym-node/tests/tsconfig.json +++ b/nym-node/tests/tsconfig.json @@ -14,7 +14,8 @@ "moduleResolution": "node", "allowSyntheticDefaultImports": true, "paths": { - "*": ["types/*"] + "*": ["types/*"], + "common/api-test-utils": ["../../common/api-test-utils/index.ts"] }, "baseUrl": "./", "typeRoots": ["node_modules/@types"], diff --git a/package.json b/package.json index dd72164411..21af7e9b86 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "lerna": "^7.3.0", "npm-run-all": "^4.1.5", "@npmcli/node-gyp": "^3.0.0", - "node-gyp": "^9.3.1" + "node-gyp": "^9.3.1", + "tslog": "3.3.3" } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index e5fc44427d..a5dc3d0952 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17535,7 +17535,7 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.16, source-map-support@^0.5.6, source-map-support@~0.5.12, source-map-support@~0.5.20: +source-map-support@^0.5.16, source-map-support@^0.5.21, source-map-support@^0.5.6, source-map-support@~0.5.12, source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== @@ -18620,6 +18620,13 @@ tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4 resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tslog@3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/tslog/-/tslog-3.3.3.tgz#751a469e0d36841bd7e03676c27e53e7ffe9bc3d" + integrity sha512-lGrkndwpAohZ9ntQpT+xtUw5k9YFV1DjsksiWQlBSf82TTqsSAWBARPRD9juI730r8o3Awpkjp2aXy9k+6vr+g== + dependencies: + source-map-support "^0.5.21" + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"