node-api test updates

This commit is contained in:
benedettadavico
2023-10-23 10:59:03 +02:00
parent 65e35bd2b0
commit 604098844a
10 changed files with 32 additions and 12 deletions
@@ -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]
);
}
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
ConfigHandler: require('./config/configHandler.ts'),
RestClient: require('./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;
+2 -2
View File
@@ -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",
@@ -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) {
+1 -1
View File
@@ -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();
+2 -1
View File
@@ -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"],
+2 -1
View File
@@ -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"
}
}
+8 -1
View File
@@ -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"