@zohodesk/testinglibrary 0.0.1 → 0.0.2-n20-experimental
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/.babelrc +23 -0
- package/.eslintrc.js +31 -0
- package/.gitlab-ci.yml +163 -0
- package/.prettierrc +6 -0
- package/README.md +98 -18
- package/bin/cli.js +2 -2
- package/bin/postinstall.js +1 -16
- package/{src → build}/core/jest/preprocessor/jsPreprocessor.js +7 -9
- package/{src → build}/core/jest/runner/jest-runner.js +46 -45
- package/build/core/jest/setup/index.js +3 -0
- package/build/core/playwright/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
- package/build/core/playwright/builtInFixtures/context.js +32 -0
- package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
- package/build/core/playwright/builtInFixtures/i18N.js +41 -0
- package/build/core/playwright/builtInFixtures/index.js +44 -0
- package/build/core/playwright/builtInFixtures/page.js +101 -0
- package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
- package/build/core/playwright/clear-caches.js +49 -0
- package/build/core/playwright/codegen.js +55 -0
- package/build/core/playwright/configuration/Configuration.js +25 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +43 -0
- package/build/core/playwright/configuration/UserArgs.js +12 -0
- package/build/core/playwright/constants/browserTypes.js +12 -0
- package/build/core/playwright/constants/fileMutexConfig.js +9 -0
- package/build/core/playwright/custom-commands.js +7 -0
- package/build/core/playwright/env-initializer.js +43 -0
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/additionalProfiles.js +18 -0
- package/build/core/playwright/helpers/auth/accountLogin.js +21 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +41 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +118 -0
- package/build/core/playwright/helpers/auth/index.js +76 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +50 -0
- package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +31 -0
- package/build/core/playwright/helpers/fileMutex.js +71 -0
- package/build/core/playwright/helpers/getUserFixtures.js +23 -0
- package/build/core/playwright/helpers/mergeObjects.js +13 -0
- package/build/core/playwright/helpers/parseUserArgs.js +10 -0
- package/build/core/playwright/index.js +24 -0
- package/build/core/playwright/readConfigFile.js +147 -0
- package/build/core/playwright/report-generator.js +42 -0
- package/build/core/playwright/runner/Runner.js +22 -0
- package/build/core/playwright/runner/RunnerHelper.js +43 -0
- package/build/core/playwright/runner/RunnerTypes.js +17 -0
- package/build/core/playwright/runner/SpawnRunner.js +110 -0
- package/build/core/playwright/setup/config-creator.js +113 -0
- package/build/core/playwright/setup/config-utils.js +189 -0
- package/build/core/playwright/setup/custom-reporter.js +136 -0
- package/build/core/playwright/setup/qc-custom-reporter.js +291 -0
- package/build/core/playwright/tagProcessor.js +69 -0
- package/build/core/playwright/test-runner.js +116 -0
- package/build/core/playwright/types.js +44 -0
- package/build/core/playwright/validateFeature.js +28 -0
- package/build/decorators.d.ts +1 -0
- package/build/decorators.js +16 -0
- package/build/index.d.ts +78 -0
- package/build/index.js +105 -0
- package/build/lib/cli.js +78 -0
- package/build/lib/post-install.js +25 -0
- package/build/lint/index.js +4 -0
- package/build/parser/parser.js +205 -0
- package/build/parser/sample.feature +34 -0
- package/build/parser/sample.spec.js +37 -0
- package/build/parser/verifier.js +130 -0
- package/build/setup-folder-structure/helper.js +37 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
- package/build/setup-folder-structure/samples/actors-index.js +2 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +15 -0
- package/build/setup-folder-structure/samples/editions-index.js +3 -0
- package/build/setup-folder-structure/samples/free-sample.json +25 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +37 -0
- package/build/setup-folder-structure/samples/settings.json +7 -0
- package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +46 -0
- package/build/setup-folder-structure/setupProject.js +122 -0
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +69 -0
- package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +27 -0
- package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
- package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
- package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
- package/build/utils/cliArgsToObject.js +72 -0
- package/build/utils/fileUtils.js +89 -0
- package/build/utils/getFilePath.js +11 -0
- package/build/utils/logger.js +57 -0
- package/build/utils/rootPath.js +53 -0
- package/build/utils/stepDefinitionsFormatter.js +11 -0
- package/changelog.md +167 -0
- package/jest.config.js +81 -63
- package/npm-shrinkwrap.json +12575 -0
- package/package.json +60 -31
- package/playwright.config.js +62 -112
- package/src/core/jest/setup/index.js +0 -165
- package/src/core/playwright/codegen.js +0 -61
- package/src/core/playwright/custom-commands.js +0 -3
- package/src/core/playwright/env-initializer.js +0 -24
- package/src/core/playwright/index.js +0 -81
- package/src/core/playwright/readConfigFile.js +0 -18
- package/src/core/playwright/report-generator.js +0 -44
- package/src/core/playwright/test-runner.js +0 -64
- package/src/index.js +0 -9
- package/src/lib/cli.js +0 -35
- package/src/utils/cliArgsToObject.js +0 -35
- package/src/utils/getFilePath.js +0 -9
- package/src/utils/logger.js +0 -28
- package/src/utils/rootPath.js +0 -19
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _fileMutex = _interopRequireDefault(require("../../../../../core/playwright/helpers/fileMutex"));
|
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
|
6
|
+
var _fs = require("fs");
|
|
7
|
+
jest.mock('fs');
|
|
8
|
+
describe('FileMutex', () => {
|
|
9
|
+
const directory = '/tmp/locks';
|
|
10
|
+
const lockFileName = 'test-lock';
|
|
11
|
+
const fileDeletionTimeoutConfig = {
|
|
12
|
+
timeout: 1000
|
|
13
|
+
};
|
|
14
|
+
const lockFilePath = _path.default.resolve(directory, lockFileName + '.lock');
|
|
15
|
+
let fileMutex;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
fileMutex = new _fileMutex.default(directory, lockFileName, fileDeletionTimeoutConfig);
|
|
19
|
+
});
|
|
20
|
+
describe('acquire', () => {
|
|
21
|
+
it('should create the lock file if it does not exist', async () => {
|
|
22
|
+
_fs.writeFileSync.mockImplementation(() => {});
|
|
23
|
+
await fileMutex.acquire();
|
|
24
|
+
expect(_fs.writeFileSync).toHaveBeenCalledWith(fileMutex.lockFilePath, 'locked');
|
|
25
|
+
});
|
|
26
|
+
it('should wait for lock file deletion if it exists', async () => {
|
|
27
|
+
_fs.existsSync.mockImplementation(filePath => filePath === fileMutex.lockFilePath);
|
|
28
|
+
_fs.watch.mockImplementation((dir, callback) => {
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
_fs.existsSync.mockImplementation(() => false);
|
|
31
|
+
callback('rename', fileMutex.lockFileName);
|
|
32
|
+
}, fileDeletionTimeoutConfig);
|
|
33
|
+
return {
|
|
34
|
+
close: jest.fn()
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
await fileMutex.acquire();
|
|
38
|
+
expect(_fs.watch).toHaveBeenCalledWith(directory, expect.any(Function));
|
|
39
|
+
});
|
|
40
|
+
it('should reject if watch timeout exceeds', async () => {
|
|
41
|
+
_fs.existsSync.mockImplementation(filePath => filePath === lockFilePath);
|
|
42
|
+
_fs.watch.mockImplementation(() => {
|
|
43
|
+
return {
|
|
44
|
+
close: jest.fn()
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
await expect(fileMutex.acquire()).rejects.toThrow('Watch timeout exceeded');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('release', () => {
|
|
51
|
+
it('should delete the lock file if it exists', async () => {
|
|
52
|
+
_fs.existsSync.mockReturnValue(true);
|
|
53
|
+
_fs.unlinkSync.mockImplementation(() => {});
|
|
54
|
+
await fileMutex.release();
|
|
55
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(lockFilePath);
|
|
56
|
+
expect(_fs.unlinkSync).toHaveBeenCalledWith(lockFilePath);
|
|
57
|
+
});
|
|
58
|
+
it('should release lock by deleting lock file', async () => {
|
|
59
|
+
_fs.existsSync.mockReturnValue(true);
|
|
60
|
+
_fs.unlinkSync.mockImplementation(() => {});
|
|
61
|
+
await fileMutex.release();
|
|
62
|
+
expect(_fs.unlinkSync).toHaveBeenCalledWith(lockFilePath);
|
|
63
|
+
});
|
|
64
|
+
it('should not attempt to delete the lock file if it does not exist', async () => {
|
|
65
|
+
_fs.existsSync.mockReturnValue(false);
|
|
66
|
+
await fileMutex.release();
|
|
67
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(lockFilePath);
|
|
68
|
+
expect(_fs.unlinkSync).not.toHaveBeenCalled();
|
|
69
|
+
});
|
|
70
|
+
it('should log an error if deleting the lock file fails', async () => {
|
|
71
|
+
const errorMessage = 'Error deleting lock file';
|
|
72
|
+
_fs.existsSync.mockReturnValue(true);
|
|
73
|
+
_fs.unlinkSync.mockImplementation(() => {
|
|
74
|
+
throw new Error(errorMessage);
|
|
75
|
+
});
|
|
76
|
+
await expect(fileMutex.release()).rejects.toThrow(errorMessage);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _fs = require("fs");
|
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
|
6
|
+
jest.mock('fs');
|
|
7
|
+
jest.mock('path');
|
|
8
|
+
jest.mock('../../../../../core/playwright/readConfigFile', () => ({
|
|
9
|
+
generateConfigFromFile: jest.fn(() => ({
|
|
10
|
+
uatDirectory: '/test/directory'
|
|
11
|
+
})),
|
|
12
|
+
getRunMode: jest.fn(() => 'dev')
|
|
13
|
+
}));
|
|
14
|
+
const {
|
|
15
|
+
getListOfActors
|
|
16
|
+
} = require('../../../../../core/playwright/helpers/auth/getUsers');
|
|
17
|
+
describe('getListOfActors', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
jest.clearAllMocks();
|
|
20
|
+
_path.default.join.mockImplementation((...args) => args.join('/'));
|
|
21
|
+
});
|
|
22
|
+
test('throws an error when config file cannot be loaded', () => {
|
|
23
|
+
_fs.existsSync.mockReturnValueOnce(true); // Main config file exists
|
|
24
|
+
|
|
25
|
+
jest.mock('/test/directory/conf/dev/actors/index.js', () => {
|
|
26
|
+
throw new Error('Loading error');
|
|
27
|
+
}, {
|
|
28
|
+
virtual: true
|
|
29
|
+
});
|
|
30
|
+
expect(() => getListOfActors()).toThrow('Error loading actor configuration from /test/directory/conf/dev/actors/index.js');
|
|
31
|
+
});
|
|
32
|
+
test('throws an error when beta feature config does not exist', () => {
|
|
33
|
+
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
34
|
+
.mockReturnValueOnce(false); // Beta feature config does not exist in either path
|
|
35
|
+
|
|
36
|
+
const betaFeature = 'nonExistentFeature';
|
|
37
|
+
expect(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
|
|
38
|
+
});
|
|
39
|
+
test('loads main configuration when betaFeature is not provided and main config file exists', () => {
|
|
40
|
+
_fs.existsSync.mockReturnValueOnce(true);
|
|
41
|
+
jest.doMock('/test/directory/conf/dev/actors/index.js', () => ({
|
|
42
|
+
actors: []
|
|
43
|
+
}), {
|
|
44
|
+
virtual: true
|
|
45
|
+
});
|
|
46
|
+
const result = getListOfActors();
|
|
47
|
+
expect(result).toEqual({
|
|
48
|
+
actors: []
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
test('falls back to default configuration if main config file does not exist', () => {
|
|
52
|
+
_fs.existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
|
|
53
|
+
jest.doMock('/test/directory/conf/default/actors/index.js', () => ({
|
|
54
|
+
actors: []
|
|
55
|
+
}), {
|
|
56
|
+
virtual: true
|
|
57
|
+
});
|
|
58
|
+
const result = getListOfActors();
|
|
59
|
+
expect(result).toEqual({
|
|
60
|
+
actors: []
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
test('loads beta feature configuration when betaFeature is provided', () => {
|
|
64
|
+
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
65
|
+
.mockReturnValueOnce(true); // Beta feature config exists
|
|
66
|
+
|
|
67
|
+
const betaFeature = 'parentchild';
|
|
68
|
+
const betaFeaturePath = `/test/directory/conf/dev/actors/beta/${betaFeature}/index.js`;
|
|
69
|
+
jest.doMock(betaFeaturePath, () => ({
|
|
70
|
+
betaActors: []
|
|
71
|
+
}), {
|
|
72
|
+
virtual: true
|
|
73
|
+
});
|
|
74
|
+
const result = getListOfActors(betaFeature);
|
|
75
|
+
expect(result).toEqual({
|
|
76
|
+
betaActors: []
|
|
77
|
+
});
|
|
78
|
+
expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _RunnerHelper = _interopRequireDefault(require("../../../../../core/playwright/runner/RunnerHelper"));
|
|
5
|
+
var _SpawnRunner = _interopRequireDefault(require("../../../../../core/playwright/runner/SpawnRunner"));
|
|
6
|
+
describe('RunnerHelper', () => {
|
|
7
|
+
describe('createRunner', () => {
|
|
8
|
+
it('should throw error on invalid runner type', () => {
|
|
9
|
+
expect(() => _RunnerHelper.default.createRunner('invalid-type', {})).toThrow("Invalid runner type");
|
|
10
|
+
});
|
|
11
|
+
it('should create a valid runner class', () => {
|
|
12
|
+
const runnerInstance = _RunnerHelper.default.createRunner('spawn', {});
|
|
13
|
+
expect(runnerInstance).toBeInstanceOf(_SpawnRunner.default); // Directly pass the result
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _RunnerHelper = _interopRequireDefault(require("../../../../../core/playwright/runner/RunnerHelper"));
|
|
5
|
+
var _Runner = _interopRequireDefault(require("../../../../../core/playwright/runner/Runner"));
|
|
6
|
+
var _Configuration = _interopRequireDefault(require("../../../../../core/playwright/configuration/Configuration"));
|
|
7
|
+
jest.mock('child_process');
|
|
8
|
+
jest.mock('../../../../../utils/logger');
|
|
9
|
+
describe('SpawnRunner', () => {
|
|
10
|
+
let spawnRunner;
|
|
11
|
+
const runnerObj = new _Runner.default();
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
const config = new _Configuration.default({});
|
|
14
|
+
config.add("bddMode", true);
|
|
15
|
+
runnerObj.setConfig(config);
|
|
16
|
+
runnerObj.setTagArgs(["--headed"]);
|
|
17
|
+
spawnRunner = _RunnerHelper.default.createRunner('spawn', runnerObj);
|
|
18
|
+
});
|
|
19
|
+
describe('run', () => {
|
|
20
|
+
it('should call runPreprocessing when bddMode is true', () => {
|
|
21
|
+
const runPreprocessingSpy = jest.spyOn(spawnRunner, 'runPreprocessing').mockResolvedValue();
|
|
22
|
+
const runPlaywrightSpy = jest.spyOn(spawnRunner, 'runPlaywright').mockResolvedValue();
|
|
23
|
+
spawnRunner.run();
|
|
24
|
+
expect(runPreprocessingSpy).toHaveBeenCalled();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cliArgsToObject = cliArgsToObject;
|
|
7
|
+
exports.objectToCliArgs = objectToCliArgs;
|
|
8
|
+
function isMatchForOption(option) {
|
|
9
|
+
return /^--./.test(option);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Converts an array of command-line arguments into an object.
|
|
14
|
+
*
|
|
15
|
+
* @param {string[]} cliArgs - An array of command-line arguments.
|
|
16
|
+
* @param {boolean} [isKeyNeedToBeAdded=true] - Indicates whether the keys should be added to the resulting object.
|
|
17
|
+
* @returns {Object} An object representing the command-line arguments, where keys are argument names (without '--') and values are argument values.
|
|
18
|
+
* If `isKeyNeedToBeAdded` is set to `false`, only values are included in the object with numeric indexes as keys.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Example usage:
|
|
22
|
+
* const args = ['--port=8080', '--verbose', 'input.txt'];
|
|
23
|
+
* const result = cliArgsToObject(args);
|
|
24
|
+
* // result will be: { port: '8080', verbose: true }
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line no-unused-vars
|
|
27
|
+
function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
|
|
28
|
+
const processEnv = {};
|
|
29
|
+
cliArgs.forEach(option => {
|
|
30
|
+
if (isMatchForOption(option)) {
|
|
31
|
+
const equIndex = option.indexOf('=');
|
|
32
|
+
let key = option.slice(2, equIndex);
|
|
33
|
+
let value = option.slice(equIndex + 1);
|
|
34
|
+
if (equIndex === -1) {
|
|
35
|
+
key = option.slice(2);
|
|
36
|
+
value = true;
|
|
37
|
+
}
|
|
38
|
+
processEnv[key] = value;
|
|
39
|
+
if (!isNaN(parseInt(value))) {
|
|
40
|
+
processEnv[key] = parseInt(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return processEnv;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Converts an object to an array of command-line arguments.
|
|
49
|
+
*
|
|
50
|
+
* @param {Object} objectToBeConverted - The object to be converted to command-line arguments.
|
|
51
|
+
* @param {(string|function(string): boolean)} [isKeyNeedToBeAdded=true] - A string representing a key, or a function that determines whether a key should be added to the resulting array.
|
|
52
|
+
* @returns {string[]} An array of command-line arguments generated from the object's key-value pairs. Keys are transformed into argument names (with '--') and values are added as argument values.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Example usage:
|
|
56
|
+
* const options = { port: 8080, verbose: true, input: 'input.txt' };
|
|
57
|
+
* const args = objectToCliArgs(options);
|
|
58
|
+
* // args will be: ['--port=8080', '--verbose', '--input=input.txt']
|
|
59
|
+
*/
|
|
60
|
+
function objectToCliArgs(objectToBeConverted, isKeyNeedToBeAdded) {
|
|
61
|
+
const argsArray = [];
|
|
62
|
+
Object.keys(objectToBeConverted).forEach(key => {
|
|
63
|
+
if (isKeyNeedToBeAdded(key)) {
|
|
64
|
+
if (typeof objectToBeConverted[key] === 'boolean' && objectToBeConverted[key]) {
|
|
65
|
+
argsArray.push(`--${key}`);
|
|
66
|
+
} else {
|
|
67
|
+
argsArray.push(`--${key}=${objectToBeConverted[key]}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return argsArray;
|
|
72
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.checkIfFileExists = checkIfFileExists;
|
|
8
|
+
exports.checkIfFolderExistsWithPattern = checkIfFolderExistsWithPattern;
|
|
9
|
+
exports.deleteFile = deleteFile;
|
|
10
|
+
exports.deleteFolder = deleteFolder;
|
|
11
|
+
exports.readFileContents = readFileContents;
|
|
12
|
+
exports.writeFileContents = writeFileContents;
|
|
13
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
14
|
+
var _path = _interopRequireDefault(require("path"));
|
|
15
|
+
var _logger = require("./logger");
|
|
16
|
+
var glob = _interopRequireWildcard(require("glob"));
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
+
function checkIfFileExists(file) {
|
|
19
|
+
try {
|
|
20
|
+
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
|
21
|
+
return true;
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_logger.Logger.error(err);
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function readFileContents(filePath) {
|
|
28
|
+
try {
|
|
29
|
+
let fileContents = _fs.default.readFileSync(filePath, 'utf-8');
|
|
30
|
+
return fileContents;
|
|
31
|
+
} catch (err) {
|
|
32
|
+
_logger.Logger.error(err);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function writeFileContents(filePath, content, writeOptions = {}) {
|
|
37
|
+
const directoryPath = _path.default.dirname(filePath);
|
|
38
|
+
|
|
39
|
+
// Check if the directory exists
|
|
40
|
+
if (!_fs.default.existsSync(directoryPath)) {
|
|
41
|
+
_fs.default.mkdirSync(directoryPath, {
|
|
42
|
+
recursive: true
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
_fs.default.writeFileSync(`${filePath}`, content, writeOptions);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
_logger.Logger.error(err);
|
|
49
|
+
throw new Error(err);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function deleteFile(filePath) {
|
|
53
|
+
if (checkIfFileExists(filePath)) {
|
|
54
|
+
try {
|
|
55
|
+
_fs.default.unlinkSync(filePath);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
_logger.Logger.error(err);
|
|
58
|
+
throw new Error(`Error while deleting the test data file: ${filePath}`);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `File Does not Exist in the path ${filePath}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function deleteFolder(folderPath) {
|
|
65
|
+
if (_fs.default.existsSync(folderPath)) {
|
|
66
|
+
try {
|
|
67
|
+
_fs.default.rmdirSync(folderPath, {
|
|
68
|
+
recursive: true
|
|
69
|
+
});
|
|
70
|
+
} catch (err) {
|
|
71
|
+
_logger.Logger.error(err);
|
|
72
|
+
throw new Error(`Error while deleting the test data file: ${folderPath}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// This function uses glob to check if a folder exists with a specific pattern
|
|
78
|
+
// Glob is define patterns for matching file and directory names based on wildcards
|
|
79
|
+
function checkIfFolderExistsWithPattern(folderPath) {
|
|
80
|
+
try {
|
|
81
|
+
if (glob.sync(folderPath).length > 0) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_logger.Logger.error(err);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getFilePathWithExtension;
|
|
7
|
+
var _os = require("os");
|
|
8
|
+
const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
|
|
9
|
+
function getFilePathWithExtension(binName) {
|
|
10
|
+
return isWindows ? `${binName}.cmd` : binName;
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Logger = void 0;
|
|
7
|
+
// const SUCCESS_TYPE = 'success';
|
|
8
|
+
// const FAILURE_TYPE = 'failure';
|
|
9
|
+
// const INFO_TYPE = 'info';
|
|
10
|
+
|
|
11
|
+
// function logger() {
|
|
12
|
+
// this.colors = {
|
|
13
|
+
// 'success': ['\x1b[36m', '\x1b[0m'],
|
|
14
|
+
// 'failure': ['\x1b[31m', '\x1b[0m'],
|
|
15
|
+
// 'info': ['\x1b[33m', '\x1b[0m']
|
|
16
|
+
// }
|
|
17
|
+
// this.consoleLogger = console;
|
|
18
|
+
// return {
|
|
19
|
+
// SUCCESS_TYPE,
|
|
20
|
+
// FAILURE_TYPE,
|
|
21
|
+
// INFO_TYPE,
|
|
22
|
+
// error: () => { },
|
|
23
|
+
// info: () => { },
|
|
24
|
+
// log: (type, message) => {
|
|
25
|
+
// const color = this.colors[type];
|
|
26
|
+
// console.log(type, color)
|
|
27
|
+
// this.consoleLogger.log(`${color[0]}${message}${color[1]}`)
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
31
|
+
|
|
32
|
+
// module.exports = {
|
|
33
|
+
// Logger: logger()
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
class LoggerImpl {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.SUCCESS_TYPE = 'success';
|
|
39
|
+
this.FAILURE_TYPE = 'failure';
|
|
40
|
+
this.INFO_TYPE = 'info';
|
|
41
|
+
this.colors = {
|
|
42
|
+
'success': ['\x1b[36m', '\x1b[0m'],
|
|
43
|
+
'failure': ['\x1b[31m', '\x1b[0m'],
|
|
44
|
+
'info': ['\x1b[33m', '\x1b[0m']
|
|
45
|
+
};
|
|
46
|
+
this.consoleLogger = console;
|
|
47
|
+
}
|
|
48
|
+
error(err) {
|
|
49
|
+
this.consoleLogger.error(err);
|
|
50
|
+
}
|
|
51
|
+
info() {}
|
|
52
|
+
log(type, message) {
|
|
53
|
+
const color = this.colors[type];
|
|
54
|
+
this.consoleLogger.log(`${color[0]}${message}${color[1]}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const Logger = exports.Logger = new LoggerImpl();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getBinPath = getBinPath;
|
|
8
|
+
exports.getExecutableBinaryPath = getExecutableBinaryPath;
|
|
9
|
+
exports.getRootNodeModulesPath = getRootNodeModulesPath;
|
|
10
|
+
exports.getRootPath = getRootPath;
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
13
|
+
var _logger = require("./logger");
|
|
14
|
+
var _getFilePath = _interopRequireDefault(require("./getFilePath"));
|
|
15
|
+
// TODO: Publish and check this change of finding package.json working fine.
|
|
16
|
+
function findPath(directory, pathToFind) {
|
|
17
|
+
const filePath = _path.default.join(directory, pathToFind);
|
|
18
|
+
if (_fs.default.existsSync(filePath)) {
|
|
19
|
+
return filePath;
|
|
20
|
+
}
|
|
21
|
+
const parentDir = _path.default.dirname(directory);
|
|
22
|
+
if (parentDir === directory) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return findPath(parentDir, pathToFind);
|
|
26
|
+
}
|
|
27
|
+
function findPackageJSON(startDir) {
|
|
28
|
+
return findPath(startDir, 'package.json');
|
|
29
|
+
}
|
|
30
|
+
function findBinaryPath(directory, command) {
|
|
31
|
+
const binaryPath = _path.default.join('.bin', (0, _getFilePath.default)(command));
|
|
32
|
+
return findPath(directory, binaryPath);
|
|
33
|
+
}
|
|
34
|
+
function getRootPath() {
|
|
35
|
+
return findPackageJSON(_path.default.resolve(__dirname));
|
|
36
|
+
}
|
|
37
|
+
function getRootNodeModulesPath() {
|
|
38
|
+
const rootPath = getRootPath();
|
|
39
|
+
return _path.default.resolve(_path.default.dirname(rootPath), 'node_modules');
|
|
40
|
+
}
|
|
41
|
+
function getBinPath(command) {
|
|
42
|
+
const packageNodeModulesPath = getRootNodeModulesPath();
|
|
43
|
+
return findBinaryPath(packageNodeModulesPath, command);
|
|
44
|
+
}
|
|
45
|
+
function getExecutableBinaryPath(command) {
|
|
46
|
+
const binPath = getBinPath(command);
|
|
47
|
+
if (binPath !== null) {
|
|
48
|
+
return binPath;
|
|
49
|
+
} else {
|
|
50
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error: Could not find executable bin ${command} file. Make sure to npm install before proceeding`);
|
|
51
|
+
process.exit();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.delimiters = void 0;
|
|
7
|
+
exports.findDelimiterFromStep = findDelimiterFromStep;
|
|
8
|
+
const delimiters = exports.delimiters = ["Given", "When", "Then", "And"];
|
|
9
|
+
function findDelimiterFromStep(step) {
|
|
10
|
+
return delimiters.find(delimiter => step.includes(delimiter));
|
|
11
|
+
}
|
package/changelog.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Testing Framework
|
|
2
|
+
|
|
3
|
+
## Framework that abstracts the configuration for playwright and Jest
|
|
4
|
+
# 0.2.4
|
|
5
|
+
- Issue fixes on custom fixtures
|
|
6
|
+
- Page Fixture
|
|
7
|
+
- i18n Fixture
|
|
8
|
+
|
|
9
|
+
# 0.2.1
|
|
10
|
+
**Issue Fixes**
|
|
11
|
+
- Fixes issue in actors configuration
|
|
12
|
+
- Added Error Logger
|
|
13
|
+
|
|
14
|
+
# 0.2.0
|
|
15
|
+
**Major Breaking Change**
|
|
16
|
+
- Removed Env-config.json in favour of conf/*/settings.json
|
|
17
|
+
- Mode in uat.config.js is deprecated. Use command args instead
|
|
18
|
+
|
|
19
|
+
**Enhancements**
|
|
20
|
+
- Playwright version updated to 1.42.1
|
|
21
|
+
- Playwright-bdd version updated to 6.1.1
|
|
22
|
+
- Tags Support
|
|
23
|
+
- Added getMetaInfo fixture to get the actors Info data
|
|
24
|
+
|
|
25
|
+
**Issue Fixes**
|
|
26
|
+
- Fixes #10- Mode config not working properly
|
|
27
|
+
|
|
28
|
+
# 0.1.9
|
|
29
|
+
**Enhancements**
|
|
30
|
+
- Added option to specify browsers in command line.
|
|
31
|
+
- npm run uat -- --browsers='chrome,firefox'
|
|
32
|
+
- Playwright version updated to 1.41.1
|
|
33
|
+
- Added option to Skip Browser download
|
|
34
|
+
- Added New Command re-run-failed to run only the failed cases
|
|
35
|
+
**Major Change**
|
|
36
|
+
- Default fixtures moved inside the library.(Page, Context, i18N, unauthenticatedPage)
|
|
37
|
+
**Internal Library Change**
|
|
38
|
+
Examples folder updated to latest testing library version.
|
|
39
|
+
|
|
40
|
+
# 0.1.8
|
|
41
|
+
**Issue Fixes**
|
|
42
|
+
- Fix #9 Custom report generate Error on Windows
|
|
43
|
+
- Add Tags annotations only on bddMode
|
|
44
|
+
|
|
45
|
+
**Enhancements**
|
|
46
|
+
- Added Failed steps in test summary
|
|
47
|
+
|
|
48
|
+
# 0.1.7
|
|
49
|
+
**Enhancements**
|
|
50
|
+
- Added option to run teardown logic.
|
|
51
|
+
- Added support for tag based filtering.
|
|
52
|
+
- Playwright-bdd version updated to 5.6.0.
|
|
53
|
+
- New fixture added to add tag as annotations in test report
|
|
54
|
+
|
|
55
|
+
**Issue Fixes**
|
|
56
|
+
- Edition command option. Fixed the edition tags not generated properly
|
|
57
|
+
|
|
58
|
+
# 0.1.6
|
|
59
|
+
|
|
60
|
+
**Enhancements**
|
|
61
|
+
- New Command option Added `--edition`.
|
|
62
|
+
- New Configuration Added `editionOrder`.
|
|
63
|
+
`In uat.config.js, editionOrder: ['Free', 'Express']`
|
|
64
|
+
- Cache Layer added
|
|
65
|
+
|
|
66
|
+
**USAGE**
|
|
67
|
+
- npm run uat --edition="Free"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# 0.1.5
|
|
72
|
+
|
|
73
|
+
**Enhancements**
|
|
74
|
+
|
|
75
|
+
- Playwright version updated to `1.40.1`
|
|
76
|
+
- And and But Support added
|
|
77
|
+
- Added Code Suggestions support
|
|
78
|
+
- Custom Reporter added. Now the report will be available in json format.
|
|
79
|
+
- New Commands added.
|
|
80
|
+
|
|
81
|
+
`- help: npx ZDTestingFramework help`
|
|
82
|
+
|
|
83
|
+
- Will list down the commands available in the tool
|
|
84
|
+
|
|
85
|
+
`- clearCaches: npx ZDTestingFramework clearCaches`
|
|
86
|
+
|
|
87
|
+
- Will clear the exisiting cookies in the authentication setup
|
|
88
|
+
|
|
89
|
+
**Issue Fixes**
|
|
90
|
+
|
|
91
|
+
- Fixed Issue that occurs while quitting node process.
|
|
92
|
+
|
|
93
|
+
# 0.1.4
|
|
94
|
+
|
|
95
|
+
- `testIdAttribute` config added
|
|
96
|
+
- Fixed issue while reading boolean configuration values
|
|
97
|
+
|
|
98
|
+
# 0.1.3
|
|
99
|
+
|
|
100
|
+
- uat config sample file updated with `bddMode` and `viewport` values
|
|
101
|
+
- user configuration issue fix when the value is undefined
|
|
102
|
+
|
|
103
|
+
# 0.1.2
|
|
104
|
+
|
|
105
|
+
- Bdd version updated to `5.4.0`
|
|
106
|
+
- Playwright version updated to `1.39.0`
|
|
107
|
+
|
|
108
|
+
# 0.1.1
|
|
109
|
+
|
|
110
|
+
- Fixed post install script error
|
|
111
|
+
- Fixed error `@cucumber/gherkin` not found. Cause of this issue is updating @cucumber/cucumber to 9.5.0. Reverting this version to 9.2.0
|
|
112
|
+
- Removed testing library exports
|
|
113
|
+
|
|
114
|
+
# 0.1.0
|
|
115
|
+
|
|
116
|
+
- Removed eslint as dev dependencies as it causes `npm aliases not supported error` for npm version < 6
|
|
117
|
+
|
|
118
|
+
# 0.0.9
|
|
119
|
+
|
|
120
|
+
- Video sized in report adjusted to viewport size
|
|
121
|
+
- Changes in package.json scripts while setting up project
|
|
122
|
+
|
|
123
|
+
# 0.0.8
|
|
124
|
+
|
|
125
|
+
- Tags Support
|
|
126
|
+
- Enable running without bddmode feature
|
|
127
|
+
- viewport configuration
|
|
128
|
+
- Internal Change - Code refactoring
|
|
129
|
+
|
|
130
|
+
# 0.0.7
|
|
131
|
+
|
|
132
|
+
- Removed react and react-dom as dependencies. Added this as peer dependency
|
|
133
|
+
|
|
134
|
+
# 0.0.6
|
|
135
|
+
|
|
136
|
+
## Provided Initial Support for cucumber feature files
|
|
137
|
+
|
|
138
|
+
- Playwright-bdd and cucumber added as dependencies
|
|
139
|
+
- Added config bddMode which toggles the feature files processing
|
|
140
|
+
- Added expect timeout and test timeout as an option
|
|
141
|
+
- Decorators support for given, when and then. Typescript support needed to use this feature
|
|
142
|
+
|
|
143
|
+
## Internal Library change
|
|
144
|
+
|
|
145
|
+
- Provided support for import/export statements
|
|
146
|
+
|
|
147
|
+
# 0.0.5
|
|
148
|
+
|
|
149
|
+
- Added Init command to initialize the folder structure and configuration for testing
|
|
150
|
+
- Renamed config.json to env-config.json
|
|
151
|
+
- Configured report file path directory and Handled Edge case in Cookies Handling
|
|
152
|
+
|
|
153
|
+
# 0.0.4
|
|
154
|
+
|
|
155
|
+
- Issue Fixes while loading the storage state
|
|
156
|
+
|
|
157
|
+
# 0.0.3
|
|
158
|
+
|
|
159
|
+
- Added Support for custom config generator based on user preferences
|
|
160
|
+
|
|
161
|
+
# 0.0.2
|
|
162
|
+
|
|
163
|
+
- Fix for Finding directories inside node_modules folder
|
|
164
|
+
|
|
165
|
+
# 0.0.1
|
|
166
|
+
|
|
167
|
+
- test and report command support
|