@zohodesk/testinglibrary 0.1.3 → 0.1.4-exp.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.
- package/.eslintrc.js +1 -1
- package/build/core/playwright/clear-caches.js +30 -0
- package/build/core/playwright/readConfigFile.js +9 -4
- package/build/core/playwright/setup/config-creator.js +16 -12
- package/build/core/playwright/setup/config-utils.js +30 -0
- package/build/core/playwright/setup/custom-reporter.js +88 -0
- package/build/index.d.ts +56 -3
- package/build/index.js +6 -2
- package/build/lib/cli.js +13 -0
- package/build/setup-folder-structure/helper.js +34 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +8 -4
- package/build/setup-folder-structure/samples/uat-config-sample.js +3 -2
- package/build/setup-folder-structure/setupProject.js +10 -5
- package/build/utils/fileUtils.js +12 -0
- package/changelog.md +5 -0
- package/npm-shrinkwrap.json +14 -13
- package/package.json +5 -5
package/.eslintrc.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fileUtils = require("../../utils/fileUtils");
|
|
10
|
+
var _logger = require("../../utils/logger");
|
|
11
|
+
var _readConfigFile = require("./readConfigFile");
|
|
12
|
+
function clearCaches() {
|
|
13
|
+
try {
|
|
14
|
+
const {
|
|
15
|
+
authFilePath,
|
|
16
|
+
reportPath
|
|
17
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
18
|
+
authFilePath.split('/').pop();
|
|
19
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting auth files present in ${authFilePath}`);
|
|
20
|
+
(0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), authFilePath));
|
|
21
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting Playwright report ${reportPath}`);
|
|
22
|
+
(0, _fileUtils.deleteFolder)(reportPath);
|
|
23
|
+
(0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), 'uat', '.features-gen'));
|
|
24
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Caches Cleared');
|
|
25
|
+
} catch (err) {
|
|
26
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error While clearing cookies');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
var _default = clearCaches;
|
|
30
|
+
exports.default = _default;
|
|
@@ -15,6 +15,7 @@ const fileName = 'uat.config.js';
|
|
|
15
15
|
exports.fileName = fileName;
|
|
16
16
|
function getDefaultConfig() {
|
|
17
17
|
return {
|
|
18
|
+
headless: false,
|
|
18
19
|
browsers: ['Chrome'],
|
|
19
20
|
trace: false,
|
|
20
21
|
video: false,
|
|
@@ -31,7 +32,10 @@ function getDefaultConfig() {
|
|
|
31
32
|
},
|
|
32
33
|
debug: false,
|
|
33
34
|
mode: 'dev',
|
|
34
|
-
additionalPages: {}
|
|
35
|
+
additionalPages: {},
|
|
36
|
+
featureFilesFolder: 'feature-files',
|
|
37
|
+
stepDefinitionsFolder: 'steps',
|
|
38
|
+
testIdAttribute: 'data-testid'
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
@@ -39,7 +43,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
39
43
|
let configurationObj = {};
|
|
40
44
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
41
45
|
let configValue = userConfiguration[configKey];
|
|
42
|
-
if (configValue && configValue !==
|
|
46
|
+
if (configValue !== null && configValue !== undefined) {
|
|
43
47
|
configurationObj[configKey] = configValue;
|
|
44
48
|
} else if (defaultConfig[configKey]) {
|
|
45
49
|
configurationObj[configKey] = defaultConfig[configKey];
|
|
@@ -67,7 +71,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
67
71
|
* @property {boolean} video - video for test cases,
|
|
68
72
|
* @property {boolean} debug - debug mode
|
|
69
73
|
* @property {string} mode: mode in which the test cases needs to run
|
|
70
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
74
|
+
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
71
75
|
* @property {string} authFilePath - File Path where the cookies stored
|
|
72
76
|
* @property {any} browsers: List of browsers
|
|
73
77
|
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
@@ -78,7 +82,8 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
78
82
|
* @property {Object} additionalPages: custom pages configuration
|
|
79
83
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
80
84
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
81
|
-
* @property {viewportConfig} viewport: viewport configuration
|
|
85
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
86
|
+
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
82
87
|
*/
|
|
83
88
|
|
|
84
89
|
/**
|
|
@@ -22,7 +22,8 @@ const {
|
|
|
22
22
|
authFilePath,
|
|
23
23
|
viewport,
|
|
24
24
|
featureFilesFolder,
|
|
25
|
-
stepDefinitionsFolder
|
|
25
|
+
stepDefinitionsFolder,
|
|
26
|
+
testIdAttribute
|
|
26
27
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
27
28
|
const projects = (0, _configUtils.getProjects)({
|
|
28
29
|
browsers,
|
|
@@ -36,6 +37,18 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
|
|
|
36
37
|
featureFilesFolder,
|
|
37
38
|
stepDefinitionsFolder
|
|
38
39
|
});
|
|
40
|
+
const testOptions = (0, _configUtils.getTestUseOptions)({
|
|
41
|
+
trace,
|
|
42
|
+
video,
|
|
43
|
+
viewport,
|
|
44
|
+
testIdAttribute
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Playwright configuration object
|
|
49
|
+
*
|
|
50
|
+
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
51
|
+
*/
|
|
39
52
|
function getPlaywrightConfig() {
|
|
40
53
|
return {
|
|
41
54
|
testDir,
|
|
@@ -47,21 +60,12 @@ function getPlaywrightConfig() {
|
|
|
47
60
|
reporter: [['html', {
|
|
48
61
|
outputFolder: reportPath,
|
|
49
62
|
open: openReportOn
|
|
50
|
-
}]],
|
|
63
|
+
}], ['list'], ['./custom-reporter.js']],
|
|
51
64
|
timeout: testTimeout,
|
|
52
65
|
expect: {
|
|
53
66
|
timeout: expectTimeout
|
|
54
67
|
},
|
|
55
|
-
use:
|
|
56
|
-
viewport,
|
|
57
|
-
trace: trace ? 'on' : 'off',
|
|
58
|
-
video: video ? {
|
|
59
|
-
mode: 'on',
|
|
60
|
-
size: {
|
|
61
|
-
...viewport
|
|
62
|
-
}
|
|
63
|
-
} : 'off'
|
|
64
|
-
},
|
|
68
|
+
use: testOptions,
|
|
65
69
|
projects: isAuthMode ? [{
|
|
66
70
|
name: 'setup',
|
|
67
71
|
testMatch: /.*\.setup\.js/,
|
|
@@ -6,10 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getProjects = getProjects;
|
|
8
8
|
exports.getTestDir = getTestDir;
|
|
9
|
+
exports.getTestUseOptions = getTestUseOptions;
|
|
9
10
|
var _test = require("@playwright/test");
|
|
10
11
|
var _path = _interopRequireDefault(require("path"));
|
|
11
12
|
var _readConfigFile = require("../readConfigFile");
|
|
12
13
|
var _bddFramework = require("../../../bdd-framework");
|
|
14
|
+
/**
|
|
15
|
+
** Playwright project configuration
|
|
16
|
+
* @returns {import('@playwright/test').Project}
|
|
17
|
+
*/
|
|
13
18
|
function getBrowserConfig({
|
|
14
19
|
browserName,
|
|
15
20
|
isAuthMode,
|
|
@@ -81,6 +86,12 @@ function getBrowserConfig({
|
|
|
81
86
|
return false;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param {*} param0
|
|
93
|
+
* @returns {import('@playwright/test').Project[]}
|
|
94
|
+
*/
|
|
84
95
|
function getProjects({
|
|
85
96
|
browsers,
|
|
86
97
|
isAuthMode,
|
|
@@ -108,4 +119,23 @@ function getTestDir(bddMode, cwd, {
|
|
|
108
119
|
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
109
120
|
publish: true
|
|
110
121
|
}) : _path.default.join(cwd, 'uat');
|
|
122
|
+
}
|
|
123
|
+
function getTestUseOptions({
|
|
124
|
+
viewport,
|
|
125
|
+
trace,
|
|
126
|
+
video,
|
|
127
|
+
testIdAttribute
|
|
128
|
+
}) {
|
|
129
|
+
let defaultTestuseOptions = {
|
|
130
|
+
viewport,
|
|
131
|
+
testIdAttribute,
|
|
132
|
+
trace: trace ? 'on' : 'off',
|
|
133
|
+
video: video ? {
|
|
134
|
+
mode: 'on',
|
|
135
|
+
size: {
|
|
136
|
+
...viewport
|
|
137
|
+
}
|
|
138
|
+
} : 'off'
|
|
139
|
+
};
|
|
140
|
+
return defaultTestuseOptions;
|
|
111
141
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fileUtils = require("../../../utils/fileUtils");
|
|
10
|
+
var _readConfigFile = require("../readConfigFile");
|
|
11
|
+
class JSONSummaryReporter {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.durationInMS = -1;
|
|
14
|
+
this.passed = [];
|
|
15
|
+
this.skipped = [];
|
|
16
|
+
this.failed = [];
|
|
17
|
+
this.warned = [];
|
|
18
|
+
this.interrupted = [];
|
|
19
|
+
this.timedOut = [];
|
|
20
|
+
this.flakey = [];
|
|
21
|
+
this.status = 'unknown';
|
|
22
|
+
this.startedAt = 0;
|
|
23
|
+
}
|
|
24
|
+
onBegin() {
|
|
25
|
+
this.startedAt = Date.now();
|
|
26
|
+
}
|
|
27
|
+
onTestEnd(test, result) {
|
|
28
|
+
const title = [];
|
|
29
|
+
const fileName = [];
|
|
30
|
+
let clean = true;
|
|
31
|
+
for (const s of test.titlePath()) {
|
|
32
|
+
if (s === '' && clean) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
clean = false;
|
|
36
|
+
title.push(s);
|
|
37
|
+
if (s.includes('.ts') || s.includes('.js')) {
|
|
38
|
+
fileName.push(s);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// This will publish the file name + line number test begins on
|
|
42
|
+
const z = `${fileName[0]}:${test.location.line}:${test.location.column}`;
|
|
43
|
+
// Using the t variable in the push will push a full test name + test description
|
|
44
|
+
const t = title.join(' > ');
|
|
45
|
+
// Set the status
|
|
46
|
+
const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
|
|
47
|
+
// Logic to push the results into the correct array
|
|
48
|
+
if (result.status === 'passed' && result.retry >= 1) {
|
|
49
|
+
this.flakey.push(z);
|
|
50
|
+
} else {
|
|
51
|
+
this[status].push(z);
|
|
52
|
+
}
|
|
53
|
+
this[status].push(z);
|
|
54
|
+
}
|
|
55
|
+
onEnd(result) {
|
|
56
|
+
this.durationInMS = Date.now() - this.startedAt;
|
|
57
|
+
this.status = result.status;
|
|
58
|
+
// removing duplicate tests from passed array
|
|
59
|
+
this.passed = this.passed.filter((element, index) => {
|
|
60
|
+
return this.passed.indexOf(element) === index;
|
|
61
|
+
});
|
|
62
|
+
// removing duplicate tests from the failed array
|
|
63
|
+
this.failed = this.failed.filter((element, index) => {
|
|
64
|
+
if (!this.passed.includes(element)) {
|
|
65
|
+
return this.failed.indexOf(element) === index;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
// removing duplicate tests from the skipped array
|
|
69
|
+
this.skipped = this.skipped.filter((element, index) => {
|
|
70
|
+
return this.skipped.indexOf(element) === index;
|
|
71
|
+
});
|
|
72
|
+
// removing duplicate tests from the timedOut array
|
|
73
|
+
this.timedOut = this.timedOut.filter((element, index) => {
|
|
74
|
+
return this.timedOut.indexOf(element) === index;
|
|
75
|
+
});
|
|
76
|
+
// removing duplicate tests from the interrupted array
|
|
77
|
+
this.interrupted = this.interrupted.filter((element, index) => {
|
|
78
|
+
return this.interrupted.indexOf(element) === index;
|
|
79
|
+
});
|
|
80
|
+
// fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
|
|
81
|
+
let {
|
|
82
|
+
reportPath
|
|
83
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
84
|
+
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', 'test-summary.json'), JSON.stringify(this, null, ' '));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
var _default = JSONSummaryReporter;
|
|
88
|
+
exports.default = _default;
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expect, test } from './core/playwright/index';
|
|
2
2
|
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
+
import {
|
|
4
|
+
PlaywrightTestArgs,
|
|
5
|
+
PlaywrightTestOptions,
|
|
6
|
+
PlaywrightWorkerArgs,
|
|
7
|
+
PlaywrightWorkerOptions,
|
|
8
|
+
TestType
|
|
9
|
+
} from '@playwright/test';
|
|
3
10
|
|
|
4
|
-
export
|
|
5
|
-
|
|
11
|
+
export type KeyValue = { [key: string]: any };
|
|
12
|
+
|
|
13
|
+
export type BuiltInFixturesWorker = PlaywrightWorkerArgs &
|
|
14
|
+
PlaywrightWorkerOptions;
|
|
15
|
+
export type BuiltInFixtures = PlaywrightTestArgs &
|
|
16
|
+
PlaywrightTestOptions &
|
|
17
|
+
BuiltInFixturesWorker;
|
|
18
|
+
|
|
19
|
+
export type FixturesArg<T extends KeyValue = {}, W extends KeyValue = {}> = T &
|
|
20
|
+
W &
|
|
21
|
+
BuiltInFixtures;
|
|
22
|
+
|
|
23
|
+
export declare let hasCustomTest: boolean;
|
|
24
|
+
|
|
25
|
+
export declare function createBdd<
|
|
26
|
+
T extends KeyValue = BuiltInFixtures,
|
|
27
|
+
W extends KeyValue = BuiltInFixturesWorker,
|
|
28
|
+
World
|
|
29
|
+
>(
|
|
30
|
+
customTest?: TestType<T, W> | null,
|
|
31
|
+
_CustomWorld?: new (...args: any[]) => World
|
|
32
|
+
): {
|
|
33
|
+
Given: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
34
|
+
When: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
35
|
+
Then: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
36
|
+
And: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
37
|
+
But: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
38
|
+
Step: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
39
|
+
Before: any;
|
|
40
|
+
After: any;
|
|
41
|
+
BeforeAll: any;
|
|
42
|
+
AfterAll: any;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type StepFunctionFixturesArg<
|
|
46
|
+
T extends KeyValue,
|
|
47
|
+
W extends KeyValue
|
|
48
|
+
> = FixturesArg<T, W>;
|
|
49
|
+
type StepFunction<T extends KeyValue, W extends KeyValue> = (
|
|
50
|
+
fixtures: StepFunctionFixturesArg<T, W>,
|
|
51
|
+
...args: any[]
|
|
52
|
+
) => unknown;
|
|
53
|
+
|
|
54
|
+
const { Given, Then, When, Step, And, But } = createBdd();
|
|
55
|
+
|
|
56
|
+
export { Given, Then, When, Step, And, But, expect, test, createBdd };
|
|
57
|
+
|
|
58
|
+
export * from '@playwright/test/types/test';
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.When = exports.Then = exports.Step = exports.Given = void 0;
|
|
6
|
+
exports.When = exports.Then = exports.Step = exports.Given = exports.But = exports.And = void 0;
|
|
7
7
|
Object.defineProperty(exports, "createBdd", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
@@ -45,4 +45,8 @@ const {
|
|
|
45
45
|
exports.Step = Step;
|
|
46
46
|
exports.When = When;
|
|
47
47
|
exports.Then = Then;
|
|
48
|
-
exports.Given = Given;
|
|
48
|
+
exports.Given = Given;
|
|
49
|
+
const And = Then;
|
|
50
|
+
exports.And = And;
|
|
51
|
+
const But = Then;
|
|
52
|
+
exports.But = But;
|
package/build/lib/cli.js
CHANGED
|
@@ -7,6 +7,8 @@ var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
|
|
|
7
7
|
var _logger = require("../utils/logger");
|
|
8
8
|
var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
|
|
9
9
|
var _parser = require("../parser/parser");
|
|
10
|
+
var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
|
|
11
|
+
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
10
12
|
// import createJestRunner from '../core/jest/runner/jest-runner';
|
|
11
13
|
|
|
12
14
|
const [,, option, ...otherOptions] = process.argv;
|
|
@@ -46,6 +48,17 @@ switch (option) {
|
|
|
46
48
|
(0, _parser.generateSpecCodeForFeatureFile)(otherOptions);
|
|
47
49
|
break;
|
|
48
50
|
}
|
|
51
|
+
case 'clearCaches':
|
|
52
|
+
{
|
|
53
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Clearing caches...');
|
|
54
|
+
(0, _clearCaches.default)();
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'help':
|
|
58
|
+
{
|
|
59
|
+
(0, _helper.default)();
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
49
62
|
default:
|
|
50
63
|
{
|
|
51
64
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands test and report');
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _commander = require("commander");
|
|
9
|
+
var _fs = require("fs");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _logger = require("../utils/logger");
|
|
12
|
+
function helpercmd() {
|
|
13
|
+
const packageJsonPath = _path.default.resolve(process.cwd(), './package.json');
|
|
14
|
+
if ((0, _fs.existsSync)(packageJsonPath) && process.argv.includes('--version')) {
|
|
15
|
+
const {
|
|
16
|
+
dependencies
|
|
17
|
+
} = require(packageJsonPath);
|
|
18
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `zohodesk/testinglibrary Version : ${dependencies['@zohodesk/testinglibrary']}`);
|
|
19
|
+
_commander.program.version(dependencies['@zohodesk/testinglibrary'] || '0.0.1');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands...');
|
|
23
|
+
_commander.program.name('npx ZDTestingFramework');
|
|
24
|
+
_commander.program.command('test').description('This command is used to execute tests');
|
|
25
|
+
_commander.program.command('init').description('This command will initialize Project');
|
|
26
|
+
_commander.program.command('report').description('This command is used to generate a report summarizing the results of executed tests.');
|
|
27
|
+
_commander.program.command('codegen').description('This command is used to assist developer to write test case');
|
|
28
|
+
_commander.program.option('--headed', 'Run tests with a headed browser.');
|
|
29
|
+
_commander.program.option('--debug', 'This command is used to initiate a debugging session');
|
|
30
|
+
_commander.program.option('--tags', 'Run specific test case with mentioned tags (Useage: -- --tags="@live")');
|
|
31
|
+
_commander.program.parse(process.argv);
|
|
32
|
+
}
|
|
33
|
+
var _default = helpercmd;
|
|
34
|
+
exports.default = _default;
|
|
@@ -2,15 +2,19 @@ import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { Logger } from '../utils/logger';
|
|
4
4
|
import { generateConfigFromFile } from '../core/playwright/readConfigFile';
|
|
5
|
-
|
|
5
|
+
const gitIgnoreAbsolutePath = path.resolve(process.cwd(), '../', '../')
|
|
6
6
|
|
|
7
7
|
const { reportPath = path.resolve(process.cwd(), 'uat', 'playwright-reports') } = generateConfigFromFile();
|
|
8
8
|
const testResultsPath = path.resolve(process.cwd(), 'uat', 'test-results');
|
|
9
9
|
|
|
10
|
-
const testResultsRelativepath = path.relative(
|
|
11
|
-
const reportRelativepath = path.relative(
|
|
10
|
+
const testResultsRelativepath = path.relative(gitIgnoreAbsolutePath, testResultsPath)
|
|
11
|
+
const reportRelativepath = path.relative(gitIgnoreAbsolutePath, reportPath)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const absolutePathfeaturegen = path.resolve(process.cwd(), 'uat', '.features-gen');
|
|
15
|
+
const featuregenRelativePath = path.relative(gitIgnoreAbsolutePath,absolutePathfeaturegen)
|
|
12
16
|
|
|
13
|
-
const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}`
|
|
17
|
+
const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}\n${featuregenRelativePath}`
|
|
14
18
|
|
|
15
19
|
function updateGitIgnore() {
|
|
16
20
|
if (existsSync(path.resolve(process.cwd(), '../', '../', '.gitignore'))) {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @property {boolean} video - video for test cases,
|
|
12
12
|
* @property {boolean} debug - debug mode
|
|
13
13
|
* @property {string} mode: mode in which the test cases needs to run
|
|
14
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
14
|
+
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
15
15
|
* @property {string} authFilePath - File Path where the cookies stored
|
|
16
16
|
* @property {any} browsers: List of browsers
|
|
17
17
|
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
* @property {Object} additionalPages: custom pages configuration
|
|
23
23
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
24
24
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
25
|
-
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is {width: 1280, height: 720 }
|
|
25
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
26
|
+
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -61,14 +61,18 @@ function createUatConfig() {
|
|
|
61
61
|
function createAuthenticationFile() {
|
|
62
62
|
const isUATexist = _path.default.resolve(process.cwd(), 'uat');
|
|
63
63
|
if ((0, _fs.existsSync)(isUATexist)) {
|
|
64
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
65
64
|
try {
|
|
66
|
-
(0, _fs.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
if (!(0, _fs.existsSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures'))) {
|
|
66
|
+
(0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures'));
|
|
67
|
+
}
|
|
68
|
+
if (!(0, _fs.existsSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'))) {
|
|
69
|
+
(0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'), {
|
|
70
|
+
recursive: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
70
73
|
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'auth.setup.js'), getSetupFileAsString('auth-setup-sample.js'), null, 2);
|
|
71
74
|
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'authUsers.json'), getSetupFileAsString('authUsers-sample.json'), null, 2);
|
|
75
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
72
76
|
} catch (err) {
|
|
73
77
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat');
|
|
74
78
|
}
|
|
@@ -91,6 +95,7 @@ function setupProject() {
|
|
|
91
95
|
createFolderForUAT();
|
|
92
96
|
createConfigJson();
|
|
93
97
|
createAuthenticationFile();
|
|
98
|
+
//updateGitIgnore()
|
|
94
99
|
// Create folder for playwright . Inside .auth folder needs to be created. user.json
|
|
95
100
|
// Add playwright and test-results to .gitignore
|
|
96
101
|
setTimeout(() => {
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.checkIfFileExists = checkIfFileExists;
|
|
8
8
|
exports.deleteFile = deleteFile;
|
|
9
|
+
exports.deleteFolder = deleteFolder;
|
|
9
10
|
exports.readFileContents = readFileContents;
|
|
10
11
|
exports.writeFileContents = writeFileContents;
|
|
11
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
@@ -50,4 +51,15 @@ function deleteFile(filePath) {
|
|
|
50
51
|
throw new Error(`Error while deleting the test data file: ${filePath}`);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
}
|
|
55
|
+
function deleteFolder(folderPath) {
|
|
56
|
+
if (_fs.default.existsSync(folderPath)) {
|
|
57
|
+
try {
|
|
58
|
+
_fs.default.rmdirSync(folderPath, {
|
|
59
|
+
recursive: true
|
|
60
|
+
});
|
|
61
|
+
} catch (err) {
|
|
62
|
+
throw new Error(`Error while deleting the test data file: ${folderPath}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
53
65
|
}
|
package/changelog.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
4
|
|
|
5
|
+
# 0.1.4
|
|
6
|
+
|
|
7
|
+
- `testIdAttribute` config added
|
|
8
|
+
- Fixed issue while reading boolean configuration values
|
|
9
|
+
|
|
5
10
|
# 0.1.3
|
|
6
11
|
|
|
7
12
|
- uat config sample file updated with `bddMode` and `viewport` values
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-exp.2",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -2577,20 +2577,20 @@
|
|
|
2577
2577
|
"integrity": "sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q=="
|
|
2578
2578
|
},
|
|
2579
2579
|
"@playwright/test": {
|
|
2580
|
-
"version": "1.
|
|
2581
|
-
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.
|
|
2582
|
-
"integrity": "sha512-
|
|
2580
|
+
"version": "1.40.0",
|
|
2581
|
+
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.0.tgz",
|
|
2582
|
+
"integrity": "sha512-PdW+kn4eV99iP5gxWNSDQCbhMaDVej+RXL5xr6t04nbKLCBwYtA046t7ofoczHOm8u6c+45hpDKQVZqtqwkeQg==",
|
|
2583
2583
|
"requires": {
|
|
2584
|
-
"playwright": "1.
|
|
2584
|
+
"playwright": "1.40.0"
|
|
2585
2585
|
},
|
|
2586
2586
|
"dependencies": {
|
|
2587
2587
|
"playwright": {
|
|
2588
|
-
"version": "1.
|
|
2589
|
-
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.
|
|
2590
|
-
"integrity": "sha512-
|
|
2588
|
+
"version": "1.40.0",
|
|
2589
|
+
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.40.0.tgz",
|
|
2590
|
+
"integrity": "sha512-gyHAgQjiDf1m34Xpwzaqb76KgfzYrhK7iih+2IzcOCoZWr/8ZqmdBw+t0RU85ZmfJMgtgAiNtBQ/KS2325INXw==",
|
|
2591
2591
|
"requires": {
|
|
2592
2592
|
"fsevents": "2.3.2",
|
|
2593
|
-
"playwright-core": "1.
|
|
2593
|
+
"playwright-core": "1.40.0"
|
|
2594
2594
|
}
|
|
2595
2595
|
}
|
|
2596
2596
|
}
|
|
@@ -3572,7 +3572,8 @@
|
|
|
3572
3572
|
"commander": {
|
|
3573
3573
|
"version": "11.0.0",
|
|
3574
3574
|
"resolved": "https://registry.npmjs.org/commander/-/commander-11.0.0.tgz",
|
|
3575
|
-
"integrity": "sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ=="
|
|
3575
|
+
"integrity": "sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==",
|
|
3576
|
+
"dev": true
|
|
3576
3577
|
},
|
|
3577
3578
|
"commondir": {
|
|
3578
3579
|
"version": "1.0.1",
|
|
@@ -6724,9 +6725,9 @@
|
|
|
6724
6725
|
}
|
|
6725
6726
|
},
|
|
6726
6727
|
"playwright-core": {
|
|
6727
|
-
"version": "1.
|
|
6728
|
-
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.
|
|
6729
|
-
"integrity": "sha512
|
|
6728
|
+
"version": "1.40.0",
|
|
6729
|
+
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.40.0.tgz",
|
|
6730
|
+
"integrity": "sha512-fvKewVJpGeca8t0ipM56jkVSU6Eo0RmFvQ/MaCQNDYm+sdvKkMBBWTE1FdeMqIdumRaXXjZChWHvIzCGM/tA/Q=="
|
|
6730
6731
|
},
|
|
6731
6732
|
"pretty-format": {
|
|
6732
6733
|
"version": "29.7.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-exp.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@babel/preset-react": "7.22.5",
|
|
24
24
|
"@cucumber/cucumber": "9.2.0",
|
|
25
|
-
"@playwright/test": "1.
|
|
25
|
+
"@playwright/test": "1.40.0",
|
|
26
26
|
"@testing-library/jest-dom": "5.11.9",
|
|
27
27
|
"@testing-library/react": "11.2.7",
|
|
28
28
|
"@testing-library/react-hooks": "7.0.2",
|
|
29
29
|
"babel-jest": "29.6.2",
|
|
30
30
|
"babel-plugin-transform-dynamic-import": "2.1.0",
|
|
31
|
-
"commander": "11.0.0",
|
|
32
31
|
"fast-glob": "3.3.1",
|
|
33
32
|
"jest": "29.6.2",
|
|
34
33
|
"jest-environment-jsdom": "29.6.2",
|
|
@@ -49,6 +48,7 @@
|
|
|
49
48
|
"@babel/plugin-transform-runtime": "7.22.15",
|
|
50
49
|
"@babel/polyfill": "7.12.1",
|
|
51
50
|
"@babel/preset-env": "7.22.15",
|
|
52
|
-
"@babel/runtime": "7.22.15"
|
|
51
|
+
"@babel/runtime": "7.22.15",
|
|
52
|
+
"commander": "^11.0.0"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|