vita-playwright 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,10 +34,17 @@ VITA Playwright helpers are written in Typescript with playwright support and a
34
34
  - [updateExcelData](#updateexceldata)
35
35
  - [deleteAllFilesUnderDir](#deleteallfilesunderdir)
36
36
  - [PDF Utilities](#pdf-utilities)
37
+ - [readPdfFile](#readpdffile)
37
38
  - [Lighthouse Utilities](#lighthouse-utilities)
38
39
  - [auditLightHouse](#auditlighthouse)
39
40
  - [createLightHouseReport](#createlighthousereport)
40
41
  - [Date Utilities](#date-utilities)
42
+ - [getDateInCustomFormat](#getdateincustomformat)
43
+ - [getPastDateInCustomFormat](#getpastdateincustomformat)
44
+ - [getFutureDateInCustomFormat](#getfuturedateincustomformat)
45
+ - [getMinDateFromMultipleDates](#getmindatefrommultipledates)
46
+ - [getMaxDateFromMultipleDates](#getmaxdatefrommultipledates)
47
+ - [calculateRelativeDate](#calculaterelativedate)
41
48
  - [Database Utilities](#database-utilities)
42
49
  - [sqlDBConnection](#sqldbconnection)
43
50
  - [executeSqlQuery](#executesqlquery)
@@ -293,10 +300,16 @@ static async updateExcelData(filePath: string, sheetname: string)
293
300
  static async deleteAllFilesUnderDir(filePath: string, sheetname: string)
294
301
  ```
295
302
  ### PDF Utilities
296
- TODO: need to add PDF Utilities
303
+ PDF reading related utilities
297
304
 
305
+ #### readPdfFile
298
306
  ```ts
299
- // will be added in next versions.
307
+ /**
308
+ * @description: it will take pdf file path as input and will return array of strings(each each line in pdf is each item in result array).
309
+ * @param {string} filePath - Complete path of the excel file, example: C:/resources/****.pdf.
310
+ * @returns { Array<string>} - returns array os string, each string represents each line in pdf
311
+ */
312
+ static async readPdfFile(filePath: string)
300
313
  ```
301
314
  ### Lighthouse Utilities
302
315
  Lighthouse utilities are used to perform Lighthouse performace testing provided by Google.
@@ -334,24 +347,93 @@ static async createLightHouseReport(filePath: string, sheetname: string)
334
347
  ```
335
348
 
336
349
  ### Date Utilities
337
- TODO: need to add Date Utilities
350
+ Date related utilities
338
351
 
339
352
  ```ts
340
353
  // will be added in next versions.
341
354
  ```
342
-
343
- ### Database Utilities
344
- TODO: need to add Database Utilities
355
+ #### getDateInCustomFormat
345
356
  ```ts
346
- // will be added in next versions
357
+ /**
358
+ * @description: returns date in required format.
359
+ * @param {string} date - date in the form of string, example: 01/01/2023.
360
+ * @param {string} format - format od date, example: DD/MM/YYYY.
361
+ * @returns {string} - returns date in given format.
362
+ */
363
+ static getDateInCustomFormat(date:any, format: string)
364
+ ```
365
+ #### getPastDateInCustomFormat
366
+ ```ts
367
+ /**
368
+ * @description: subtracts no of days|months|years|hours|minutes|seconds from given date.
369
+ * @param {string} date - date in the form of string, example: 01/01/2023.
370
+ * @param {string} format - format od date, example: DD/MM/YYYY.
371
+ * @param {string} durationType - example days, months, years, hours, minutes, seconds.
372
+ * @param {string} duration - no of days|months|years|hours|minutes|seconds.
373
+ * @returns {string} - returns date in given format.
374
+ */
375
+ static getPastDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1)
376
+ ```
377
+ #### getFutureDateInCustomFormat
378
+ ```ts
379
+ /**
380
+ * @description: adds no of days|months|years|hours|minutes|seconds from given date.
381
+ * @param {string} date - date in the form of string, example: 01/01/2023.
382
+ * @param {string} format - format od date, example: DD/MM/YYYY.
383
+ * @param {string} durationType - example days, months, years, hours, minutes, seconds.
384
+ * @param {string} duration - no of days|months|years|hours|minutes|seconds.
385
+ * @returns {string} - returns date in given format.
386
+ */
387
+ static getFutureDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1)
388
+ ```
389
+ #### getMinDateFromMultipleDates
390
+ ```ts
391
+ /**
392
+ * @description: return min date from given dates.
393
+ * @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
394
+ * @returns {string} - return min date amount given dates example: 10/01/2023.
395
+ */
396
+ static getMinDateFromMultipleDates(datesArrayObject: any)
397
+ ```
398
+ #### getMaxDateFromMultipleDates
399
+ ```ts
400
+ /**
401
+ * @description: return max date from given dates.
402
+ * @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
403
+ * @returns {string} - return max date amount given dates example: 20/01/2023.
404
+ */
405
+ ```
406
+ #### calculateRelativeDate
407
+ ```ts
408
+ /**
409
+ * @description: returns no of days "lessthan|Greaterthan" from given date.
410
+ * @param {string} fromDate - date in the form of string, example: 01/01/2023.
411
+ * @param {string} format - format od date, example: DD/MM/YYYY.
412
+ * @returns {string} - returns string which is no of days "lessthan|Greaterthan" from given date.
413
+ */
414
+ static calculateRelativeDate(fromDate: any, format: string)
347
415
  ```
416
+ ### Database Utilities
417
+ Utilities related SQL server utilities
418
+
348
419
  #### sqlDBConnection
349
420
  ```ts
350
- // will be added in next versions
421
+ /**
422
+ * @description: establish the connection with database.
423
+ * @param {string} configuration - example: {server: string, database: string, username:string, password: string, portNumber: number}.
424
+ * @returns {Connection} - returns connection object.
425
+ */
426
+ static sqlDBConnection(fromDate: any, format: string)
351
427
  ```
352
428
  #### executeSqlQuery
353
429
  ```ts
354
- // will be added in next versions
430
+ /**
431
+ * @description: establish the connection with database.
432
+ * @param {string} connectionObj - connection object which will come from sqlDBConnection()
433
+ * @param {string} queryString - query to execute
434
+ * @returns {Connection} - returns connection object.
435
+ */
436
+ static async executeSqlQuery(connectionObj: any, queryString: any)
355
437
  ```
356
438
 
357
439
  ### Data Comparisions
@@ -0,0 +1,9 @@
1
+ import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
2
+ export declare class Dateutility {
3
+ static getDateInCustomFormat(date: any, format: string): string;
4
+ static getFutureDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
5
+ static getPastDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
6
+ static getMinDateFromMultipleDates(datesArrayObject: any): moment.Moment;
7
+ static getMaxDateFromMultipleDates(date1: any, date2: any): moment.Moment;
8
+ static calculateRelativeDate(fromDate: any, format: string): string;
9
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Dateutility = void 0;
7
+ const lodash_1 = require("lodash");
8
+ const moment_1 = __importDefault(require("moment"));
9
+ class Dateutility {
10
+ static getDateInCustomFormat(date, format) {
11
+ return (0, moment_1.default)(date).format(format);
12
+ }
13
+ static getFutureDateInCustomFormat(date, format, durationType, duration) {
14
+ return (0, moment_1.default)(date).add(duration, durationType).format(format);
15
+ }
16
+ static getPastDateInCustomFormat(date, format, durationType, duration) {
17
+ return (0, moment_1.default)(date).subtract(duration, durationType).format(format);
18
+ }
19
+ static getMinDateFromMultipleDates(datesArrayObject) {
20
+ return moment_1.default.min((0, lodash_1.map)(datesArrayObject, (obj) => (0, moment_1.default)(obj.date, obj.format)));
21
+ }
22
+ static getMaxDateFromMultipleDates(date1, date2) {
23
+ return moment_1.default.max(date1, date2);
24
+ }
25
+ static calculateRelativeDate(fromDate, format) {
26
+ return (0, moment_1.default)(fromDate, format).fromNow();
27
+ }
28
+ }
29
+ exports.Dateutility = Dateutility;
30
+ //# sourceMappingURL=date_utilitites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date_utilitites.js","sourceRoot":"","sources":["../../../src/utils/date_utilitites.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6B;AAC7B,oDAAsE;AACtE,MAAa,WAAW;IAEpB,MAAM,CAAC,qBAAqB,CAAC,IAAQ,EAAE,MAAc;QACjD,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACrH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACnH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,gBAAqB;QACpD,OAAO,gBAAM,CAAC,GAAG,CAAC,IAAA,YAAG,EAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,gBAAM,EAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,KAAU,EAAE,KAAU;QACrD,OAAO,gBAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,qBAAqB,CAAC,QAAa,EAAE,MAAc;QACtD,OAAO,IAAA,gBAAM,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9C,CAAC;CACJ;AAzBD,kCAyBC"}
@@ -1,2 +1,3 @@
1
1
  export declare class PDFUtility {
2
+ static readPdfFile(filePath: string): Promise<unknown>;
2
3
  }
@@ -1,7 +1,32 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.PDFUtility = void 0;
13
+ const pdfreader_1 = require("pdfreader");
4
14
  class PDFUtility {
15
+ static readPdfFile(filePath) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const items = [];
18
+ return new Promise((resolve, reject) => {
19
+ new pdfreader_1.PdfReader().parseFileItems(filePath, (err, item) => {
20
+ if (err)
21
+ reject(err);
22
+ else if (!item)
23
+ resolve(items);
24
+ else if (item.text)
25
+ items.push(item.text);
26
+ });
27
+ });
28
+ });
29
+ }
5
30
  }
6
31
  exports.PDFUtility = PDFUtility;
7
32
  //# sourceMappingURL=pdf_utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pdf_utility.js","sourceRoot":"","sources":["../../../src/utils/pdf_utility.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;CAUtB;AAVD,gCAUC"}
1
+ {"version":3,"file":"pdf_utility.js","sourceRoot":"","sources":["../../../src/utils/pdf_utility.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsC;AACtC,MAAa,UAAU;IAEnB,MAAM,CAAO,WAAW,CAAC,QAAgB;;YACrC,MAAM,KAAK,GAAG,EAAE,CAAC;YACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,IAAI,qBAAS,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;oBACnD,IAAI,GAAG;wBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;yBAChB,IAAI,CAAC,IAAI;wBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;yBAC1B,IAAI,IAAI,CAAC,IAAI;wBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAZD,gCAYC"}
@@ -1,11 +1,6 @@
1
1
  export declare class TestData {
2
- static sqlDBConnection(): Promise<any>;
3
- static executeSqlQuery(pool1: {
4
- connect: () => any;
5
- on: (arg0: string, arg1: (err: any) => void) => void;
6
- request: () => any;
7
- close: () => void;
8
- }, queryString: any): Promise<any>;
2
+ static sqlDBConnection(configuration: any): Promise<any>;
3
+ static executeSqlQuery(connectionObj: any, queryString: any): Promise<any>;
9
4
  static generateRandomUniqeIDNumber(): Promise<string>;
10
5
  static getUTCTimeCustom24hrs(localTime: string): Promise<string>;
11
6
  static waitFortimeOut(waitTime: any): Promise<void>;
@@ -13,15 +13,17 @@ exports.TestData = void 0;
13
13
  // const cosmosClient = require("@azure/cosmos").CosmosClient;
14
14
  const sql = require('mssql');
15
15
  class TestData {
16
- static sqlDBConnection() {
16
+ static sqlDBConnection(configuration) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- var server = "zwetrvl2sqd001.database.windows.net";
19
- var database = "zwetrvl2sqd001-DB002";
18
+ // var server = "zwetrvl2sqd001.database.windows.net";
19
+ // var database ="zwetrvl2sqd001-DB002";
20
20
  var config = {
21
- server: server,
22
- user: "zwetrvl2sqd001-admin",
23
- password: "SADJ+zyhcj2l(SY9",
24
- database: database,
21
+ server: configuration.server,
22
+ // user: "zwetrvl2sqd001-admin",
23
+ // password: "SADJ+zyhcj2l(SY9",
24
+ user: configuration.user,
25
+ password: configuration.password,
26
+ database: configuration.database,
25
27
  requestTimeout: 600000,
26
28
  port: 1433,
27
29
  options: {
@@ -36,16 +38,16 @@ class TestData {
36
38
  return conn;
37
39
  });
38
40
  }
39
- static executeSqlQuery(pool1, queryString) {
41
+ static executeSqlQuery(connectionObj, queryString) {
40
42
  return __awaiter(this, void 0, void 0, function* () {
41
- var pool1Connect = yield pool1.connect();
42
- pool1.on('error', err => {
43
+ var pool1Connect = yield connectionObj.connect();
44
+ connectionObj.on('error', err => {
43
45
  console.log(err);
44
46
  return;
45
47
  });
46
48
  yield pool1Connect;
47
49
  try {
48
- const request = pool1.request(); // or: new sql.Request(pool1)
50
+ const request = connectionObj.request(); // or: new sql.Request(pool1)
49
51
  const result = yield request.query(queryString);
50
52
  return result;
51
53
  }
@@ -53,7 +55,7 @@ class TestData {
53
55
  console.error('SQL error', err);
54
56
  return null;
55
57
  }
56
- pool1.close();
58
+ connectionObj.close();
57
59
  });
58
60
  }
59
61
  static generateRandomUniqeIDNumber() {
@@ -1 +1 @@
1
- {"version":3,"file":"test_data.js","sourceRoot":"","sources":["../../../src/utils/test_data.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAA8D;AAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,MAAa,QAAQ;IAEjB,MAAM,CAAO,eAAe;;YACxB,IAAI,MAAM,GAAG,qCAAqC,CAAC;YACnD,IAAI,QAAQ,GAAE,sBAAsB,CAAC;YACrC,IAAI,MAAM,GAAG;gBACT,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE,kBAAkB;gBAC5B,QAAQ,EAAE,QAAQ;gBAClB,cAAc,EAAE,MAAM;gBACtB,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE;oBACL,OAAO,EAAE,IAAI,CAAC,sCAAsC;iBACvD;gBACD,cAAc,EAAE;oBACZ,2DAA2D;oBAC3D,IAAI,EAAE,SAAS;iBAElB;aACJ,CAAC;YACF,IAAI,IAAI,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC;QAEhB,CAAC;KAAA;IACD,MAAM,CAAO,eAAe,CAAC,KAA2H,EAAE,WAAgB;;YACt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EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;YAC9E,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9D,OAAO,SAAS,CAAC,WAAW,EAAE,CAAA;QAElC,CAAC;KAAA;CAEJ;AA3HD,4BA2HC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vita-playwright",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "email": "noreply_testautomation@vialto.com",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,9 +32,10 @@
32
32
  "is-ci": "2.0.0",
33
33
  "lighthouse": "^9.6.8",
34
34
  "lodash": "^4.17.21",
35
+ "moment": "^2.29.4",
35
36
  "mssql": "9.0.0",
36
37
  "open": "8.4.0",
37
- "pdf-lib": "^1.17.1",
38
+ "pdfreader": "^3.0.0",
38
39
  "playwright": "^1.25.0",
39
40
  "playwright-lighthouse": "^2.2.2",
40
41
  "prettier": "2.7.1",
@@ -47,7 +48,7 @@
47
48
  },
48
49
  "author": "Vialto QE",
49
50
  "license": "ISC",
50
- "description": "common functions for VITA framework",
51
+ "description": "common functions for playwright and nodejs",
51
52
  "repository": {
52
53
  "type": "git",
53
54
  "url": "https://github.com/Vialto/vialto-test-automation/"
@@ -0,0 +1,28 @@
1
+ import { map } from 'lodash';
2
+ import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
3
+ export class Dateutility{
4
+
5
+ static getDateInCustomFormat(date:any, format: string){
6
+ return moment(date).format(format);
7
+ }
8
+
9
+ static getFutureDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1){
10
+ return moment(date).add(duration, durationType).format(format);
11
+ }
12
+
13
+ static getPastDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1){
14
+ return moment(date).subtract(duration, durationType).format(format);
15
+ }
16
+
17
+ static getMinDateFromMultipleDates(datesArrayObject: any){
18
+ return moment.min(map(datesArrayObject, (obj) => moment(obj.date, obj.format)));
19
+ }
20
+
21
+ static getMaxDateFromMultipleDates(date1: any, date2: any){
22
+ return moment.max(date1, date2);
23
+ }
24
+
25
+ static calculateRelativeDate(fromDate: any, format: string){
26
+ return moment(fromDate, format).fromNow();
27
+ }
28
+ }
@@ -1,13 +1,14 @@
1
- import { degrees, PDFDocument, rgb, StandardFonts } from 'pdf-lib';
2
- import fs from 'fs';
1
+ import { PdfReader } from "pdfreader";
3
2
  export class PDFUtility {
4
3
 
5
- // static async readData() {
6
- // const existingPdfBytes = fs.readFile("C:/Users/vtpr271/Downloads/SS - Global Decision Tree - Apr 2021 update (new manual outcome) (1).pdf");
7
- // // Load a PDFDocument from the existing PDF bytes
8
- // const pdfDoc = await PDFDocument.load(existingPdfBytes);
9
- // // Load a PDFDocument from the existing PDF bytes
10
- // const pdfDoc2 = await PDFDocument.load(existingPdfBytes);
11
- // console.log(pdfDoc2);
12
- // }
4
+ static async readPdfFile(filePath: string) {
5
+ const items = [];
6
+ return new Promise((resolve, reject) => {
7
+ new PdfReader().parseFileItems(filePath, (err, item) => {
8
+ if (err) reject(err);
9
+ else if (!item) resolve(items);
10
+ else if (item.text) items.push(item.text);
11
+ });
12
+ });
13
+ }
13
14
  }
@@ -3,14 +3,16 @@ const sql = require('mssql');
3
3
 
4
4
  export class TestData {
5
5
 
6
- static async sqlDBConnection() {
7
- var server = "zwetrvl2sqd001.database.windows.net";
8
- var database ="zwetrvl2sqd001-DB002";
6
+ static async sqlDBConnection(configuration: any) {
7
+ // var server = "zwetrvl2sqd001.database.windows.net";
8
+ // var database ="zwetrvl2sqd001-DB002";
9
9
  var config = {
10
- server: server,
11
- user: "zwetrvl2sqd001-admin",
12
- password: "SADJ+zyhcj2l(SY9",
13
- database: database,
10
+ server: configuration.server,
11
+ // user: "zwetrvl2sqd001-admin",
12
+ // password: "SADJ+zyhcj2l(SY9",
13
+ user: configuration.user,
14
+ password: configuration.password,
15
+ database: configuration.database,
14
16
  requestTimeout: 600000,
15
17
  port: 1433,
16
18
  options: {
@@ -26,22 +28,22 @@ export class TestData {
26
28
  return conn;
27
29
 
28
30
  }
29
- static async executeSqlQuery(pool1: { connect: () => any; on: (arg0: string, arg1: (err: any) => void) => void; request: () => any; close: () => void; }, queryString: any) {
30
- var pool1Connect = await pool1.connect();
31
- pool1.on('error', err => {
31
+ static async executeSqlQuery(connectionObj: any, queryString: any) {
32
+ var pool1Connect = await connectionObj.connect();
33
+ connectionObj.on('error', err => {
32
34
  console.log(err);
33
35
  return;
34
36
  })
35
37
  await pool1Connect;
36
38
  try {
37
- const request = pool1.request(); // or: new sql.Request(pool1)
39
+ const request = connectionObj.request(); // or: new sql.Request(pool1)
38
40
  const result = await request.query(queryString)
39
41
  return result;
40
42
  } catch (err) {
41
43
  console.error('SQL error', err);
42
44
  return null;
43
45
  }
44
- pool1.close();
46
+ connectionObj.close();
45
47
 
46
48
  }
47
49