vasu-playwright-utils 0.4.0 → 0.4.2

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.
@@ -1,7 +1,10 @@
1
1
  export * from './utils/action-utils';
2
+ export * from './utils/assert-utils';
2
3
  export * from './utils/element-utils';
3
4
  export * from './utils/locator-utils';
4
5
  export * from './utils/page-utils';
5
6
  export * from './constants';
7
+ export * from './setup';
6
8
  export * from './types';
9
+ export { default as CustomLogger } from './setup/custom-logger';
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vasu-playwright-lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vasu-playwright-lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomLogger = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  tslib_1.__exportStar(require("./utils/action-utils"), exports);
6
+ tslib_1.__exportStar(require("./utils/assert-utils"), exports);
5
7
  tslib_1.__exportStar(require("./utils/element-utils"), exports);
6
8
  tslib_1.__exportStar(require("./utils/locator-utils"), exports);
7
9
  tslib_1.__exportStar(require("./utils/page-utils"), exports);
8
10
  tslib_1.__exportStar(require("./constants"), exports);
11
+ tslib_1.__exportStar(require("./setup"), exports);
9
12
  tslib_1.__exportStar(require("./types"), exports);
13
+ var custom_logger_1 = require("./setup/custom-logger");
14
+ Object.defineProperty(exports, "CustomLogger", { enumerable: true, get: function () { return tslib_1.__importDefault(custom_logger_1).default; } });
10
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vasu-playwright-lib/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqC;AACrC,gEAAsC;AACtC,gEAAsC;AACtC,6DAAmC;AACnC,sDAA4B;AAC5B,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vasu-playwright-lib/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAqC;AACrC,+DAAqC;AACrC,gEAAsC;AACtC,gEAAsC;AACtC,6DAAmC;AACnC,sDAA4B;AAC5B,kDAAwB;AACxB,kDAAwB;AACxB,uDAAgE;AAAvD,sIAAA,OAAO,OAAgB"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * custom-logger.ts: This module provides a custom logger for Playwright tests. It implements the Reporter interface from Playwright
3
+ * and uses the Winston logging library to provide detailed logs for test execution. The logger includes custom colors
4
+ * for different log levels and can be configured to log to the console or a file.
5
+ */
6
+ import { Reporter, TestCase, TestError, TestResult } from '@playwright/test/reporter';
7
+ import winston from 'winston';
8
+ /**
9
+ * Logger configuration
10
+ */
11
+ export declare const logger: winston.Logger;
12
+ /**
13
+ * CustomLogger class that implements the Reporter interface from Playwright
14
+ */
15
+ export default class CustomLogger implements Reporter {
16
+ /**
17
+ * Logs the start of a test case
18
+ * @param {TestCase} test - The test case that is starting
19
+ */
20
+ onTestBegin(test: TestCase): void;
21
+ /**
22
+ * Logs the end of a test case
23
+ * @param {TestCase} test - The test case that ended
24
+ * @param {TestResult} result - The result of the test case
25
+ */
26
+ onTestEnd(test: TestCase, result: TestResult): void;
27
+ /**
28
+ * Logs an error
29
+ * @param {TestError} error - The error
30
+ */
31
+ onError(error: TestError): void;
32
+ }
33
+ //# sourceMappingURL=custom-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-logger.d.ts","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/setup/custom-logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,OAAO,MAAM,SAAS,CAAC;AAW9B;;GAEG;AACH,eAAO,MAAM,MAAM,gBAcjB,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,QAAQ;IACnD;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAIjC;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI;IAanD;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;CAGhC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * custom-logger.ts: This module provides a custom logger for Playwright tests. It implements the Reporter interface from Playwright
4
+ * and uses the Winston logging library to provide detailed logs for test execution. The logger includes custom colors
5
+ * for different log levels and can be configured to log to the console or a file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.logger = void 0;
9
+ const tslib_1 = require("tslib");
10
+ const winston_1 = tslib_1.__importDefault(require("winston"));
11
+ /**
12
+ * Custom colors for the logger
13
+ */
14
+ const customColors = {
15
+ info: 'blue',
16
+ error: 'red',
17
+ };
18
+ winston_1.default.addColors(customColors);
19
+ /**
20
+ * Logger configuration
21
+ */
22
+ exports.logger = winston_1.default.createLogger({
23
+ level: 'info',
24
+ format: winston_1.default.format.combine(winston_1.default.format.colorize({ all: true }), winston_1.default.format.timestamp(), winston_1.default.format.printf(({ timestamp, level, message }) => {
25
+ return `${timestamp} [${level}]: ${message}`;
26
+ })),
27
+ transports: [
28
+ new winston_1.default.transports.Console(),
29
+ // If you want to log to a file uncomment below line
30
+ // new winston.transports.File({ filename: 'logs/info.log', level: 'info' }),
31
+ ],
32
+ });
33
+ /**
34
+ * CustomLogger class that implements the Reporter interface from Playwright
35
+ */
36
+ class CustomLogger {
37
+ /**
38
+ * Logs the start of a test case
39
+ * @param {TestCase} test - The test case that is starting
40
+ */
41
+ onTestBegin(test) {
42
+ exports.logger.info(`Test Case Started : ${test.title}`);
43
+ }
44
+ /**
45
+ * Logs the end of a test case
46
+ * @param {TestCase} test - The test case that ended
47
+ * @param {TestResult} result - The result of the test case
48
+ */
49
+ onTestEnd(test, result) {
50
+ if (result.status === 'passed') {
51
+ exports.logger.info(`\x1b[32mTest Case Passed : ${test.title}\x1b[0m`); // Green color
52
+ }
53
+ else if (result.status === 'skipped') {
54
+ exports.logger.info(`\x1b[33mTest Case Skipped : ${test.title}\x1b[0m`); // Yellow color
55
+ }
56
+ else if (result.status === 'failed' && result.error) {
57
+ // Playwright inbuild reporter logs the error
58
+ // logger.error(
59
+ // `Test Case Failed: ${test.title} Error: ${result.error.message}`,
60
+ // );
61
+ }
62
+ }
63
+ /**
64
+ * Logs an error
65
+ * @param {TestError} error - The error
66
+ */
67
+ onError(error) {
68
+ exports.logger.error(error.message);
69
+ }
70
+ }
71
+ exports.default = CustomLogger;
72
+ //# sourceMappingURL=custom-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-logger.js","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/setup/custom-logger.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAGH,8DAA8B;AAE9B;;GAEG;AACH,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,KAAK;CACb,CAAC;AACF,iBAAO,CAAC,SAAS,CAAC,YAAY,CAAC,C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O,CAAC,KAAgB;QACtB,cAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CACF;AAlCD,+BAkCC"}
@@ -0,0 +1,3 @@
1
+ export * from './custom-logger';
2
+ export * from './page-setup';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/setup/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./custom-logger"), exports);
5
+ tslib_1.__exportStar(require("./page-setup"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/setup/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,uDAA6B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * page-setup.ts: This module is responsible for setting up the initial state of a page before each test.
3
+ * It includes a hook that runs before each test, setting the page context. By centralizing these setup operations,
4
+ * it ensures a consistent starting point for each test, improving test reliability. It also exports a base test object
5
+ * with a beforeEach hook already set up. This can be used to define tests with the page context set up.
6
+ */
7
+ /**
8
+ * The base test object with a beforeEach hook already set up.
9
+ * This can be used to define tests with the page context set up.
10
+ */
11
+ export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
12
+ //# sourceMappingURL=page-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-setup.d.ts","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/setup/page-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH;;;GAGG;AACH,eAAO,MAAM,IAAI,6OAAW,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * page-setup.ts: This module is responsible for setting up the initial state of a page before each test.
4
+ * It includes a hook that runs before each test, setting the page context. By centralizing these setup operations,
5
+ * it ensures a consistent starting point for each test, improving test reliability. It also exports a base test object
6
+ * with a beforeEach hook already set up. This can be used to define tests with the page context set up.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.test = void 0;
10
+ const test_1 = require("@playwright/test");
11
+ const page_utils_1 = require("../utils/page-utils");
12
+ /**
13
+ * A hook that runs before each test, setting the page context.
14
+ * @param {Page} page - The page context provided by Playwright.
15
+ */
16
+ test_1.test.beforeEach(({ page }) => {
17
+ (0, page_utils_1.setPage)(page);
18
+ });
19
+ /**
20
+ * The base test object with a beforeEach hook already set up.
21
+ * This can be used to define tests with the page context set up.
22
+ */
23
+ exports.test = test_1.test;
24
+ //# sourceMappingURL=page-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-setup.js","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/setup/page-setup.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2CAA0D;AAC1D,oDAA8C;AAE9C;;;GAGG;AACH,WAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAkB,EAAE,EAAE;IAC/C,IAAA,oBAAO,EAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACU,QAAA,IAAI,GAAG,WAAQ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './action-utils';
2
+ export * from './assert-utils';
2
3
  export * from './element-utils';
3
4
  export * from './locator-utils';
4
5
  export * from './page-utils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/utils/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAG/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
- // utils/index.ts
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  const tslib_1 = require("tslib");
5
- // Export everything from ActionUtils.ts
6
4
  tslib_1.__exportStar(require("./action-utils"), exports);
7
- // Export everything from ElementUtils.ts
5
+ tslib_1.__exportStar(require("./assert-utils"), exports);
8
6
  tslib_1.__exportStar(require("./element-utils"), exports);
9
- // Export everything from LocatorUtils.ts
10
7
  tslib_1.__exportStar(require("./locator-utils"), exports);
11
- // Export everything from PageUtils.ts
12
8
  tslib_1.__exportStar(require("./page-utils"), exports);
13
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/utils/index.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;AAEjB,wCAAwC;AACxC,yDAA+B;AAE/B,yCAAyC;AACzC,0DAAgC;AAEhC,yCAAyC;AACzC,0DAAgC;AAEhC,sCAAsC;AACtC,uDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vasu-playwright-lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,yDAA+B;AAC/B,0DAAgC;AAChC,0DAAgC;AAChC,uDAA6B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vasu-playwright-utils",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Playwright Typescript Library with reusable utilities",
5
5
  "main": "./dist/vasu-playwright-lib/index.js",
6
6
  "types": "./dist/vasu-playwright-lib/index.d.ts",