@zohodesk/testinglibrary 0.5.3-n18-experimental → 0.5.4-n18-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/README.md +8 -0
- package/build/core/playwright/builtInFixtures/page.js +2 -1
- package/build/core/playwright/clear-caches.js +2 -5
- package/build/core/playwright/configuration/ConfigurationHelper.js +5 -7
- package/build/core/playwright/constants/reporterConstants.js +2 -6
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +9 -10
- package/build/core/playwright/helpers/auth/getUsers.js +14 -14
- package/build/core/playwright/helpers/auth/index.js +1 -8
- package/build/core/playwright/helpers/auth/loginSteps.js +5 -4
- package/build/core/playwright/helpers/configFileNameProvider.js +8 -15
- package/build/core/playwright/readConfigFile.js +9 -8
- package/build/core/playwright/setup/ProjectConfiguration.js +26 -9
- package/build/core/playwright/setup/config-creator.js +5 -8
- package/build/core/playwright/setup/config-utils.js +3 -7
- package/build/core/playwright/setup/qc-custom-reporter.js +1 -4
- package/build/core/playwright/test-runner.js +6 -4
- package/build/index.js +0 -6
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +13 -54
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +26 -29
- package/build/utils/commonUtils.js +1 -4
- package/npm-shrinkwrap.json +176 -125
- package/package.json +1 -2
- package/playwright.config.js +7 -10
- package/build/core/playwright/constants/configConstants.js +0 -14
- package/build/core/playwright/helpers/configPathResolver.js +0 -38
- package/build/test/core/playwright/helpers/__tests__/configPathResolver.test.js +0 -55
- package/unit_reports/unit-report.html +0 -260
|
@@ -4,72 +4,31 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
var _fs = require("fs");
|
|
5
5
|
var _path = _interopRequireDefault(require("path"));
|
|
6
6
|
var _configFileNameProvider = require("../../../../../core/playwright/helpers/configFileNameProvider");
|
|
7
|
-
var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
|
|
8
7
|
jest.mock('fs');
|
|
9
|
-
jest.mock('path'
|
|
10
|
-
resolve: jest.fn()
|
|
11
|
-
}));
|
|
12
|
-
jest.mock("../../../../../core/playwright/helpers/configPathResolver", () => ({
|
|
13
|
-
getConfigPath: jest.fn()
|
|
14
|
-
}));
|
|
8
|
+
jest.mock('path');
|
|
15
9
|
const mockCwd = '/mock/current/directory';
|
|
16
10
|
_path.default.resolve = jest.fn();
|
|
17
11
|
process.cwd = jest.fn(() => mockCwd);
|
|
18
12
|
describe('getUATFileName', () => {
|
|
19
13
|
beforeEach(() => {
|
|
20
14
|
jest.clearAllMocks();
|
|
21
|
-
_path.default.resolve.mockImplementation((...segments) => segments.join('/'));
|
|
22
15
|
});
|
|
23
|
-
test('
|
|
24
|
-
const stage = 'uat';
|
|
16
|
+
test('return the pipeline matched config files for pipeline matched files exists', () => {
|
|
25
17
|
const mode = 'cd';
|
|
26
|
-
|
|
27
|
-
_fs.existsSync.mockReturnValue(true);
|
|
28
|
-
const expected = `${process.cwd()}/${stage}/conf/${mode}/uat.config.js`;
|
|
29
|
-
const result = (0, _configFileNameProvider.getUATFileName)(stage, mode);
|
|
30
|
-
expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith(stage);
|
|
31
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(expected);
|
|
32
|
-
expect(result).toBe(expected);
|
|
33
|
-
});
|
|
34
|
-
test('should use default stage and mode when not provided', () => {
|
|
35
|
-
const mode = 'dev';
|
|
36
|
-
const stageConfigPath = 'uat/conf';
|
|
37
|
-
const expectedPath = `${mockCwd}/${stageConfigPath}/${mode}/uat.config.js`;
|
|
18
|
+
const mockPath = `${mockCwd}/uat/conf/${mode}/uat.config.js`;
|
|
38
19
|
_fs.existsSync.mockReturnValue(true);
|
|
20
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
39
21
|
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
40
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(
|
|
41
|
-
expect(result).toBe(
|
|
42
|
-
});
|
|
43
|
-
test('should return the default config files for pipeline matched files not exists', () => {
|
|
44
|
-
const mockStage = 'uat';
|
|
45
|
-
const mockMode = 'ci';
|
|
46
|
-
const stageConfigPath = 'uat/conf';
|
|
47
|
-
const nonExistingPath = `${mockCwd}/${stageConfigPath}/${mockMode}/uat.config.js`;
|
|
48
|
-
const expectedDefaultPath = `${mockCwd}/${mockStage}/conf/default/uat.config.js`;
|
|
49
|
-
_configPathResolver.getConfigPath.mockReturnValue(stageConfigPath);
|
|
50
|
-
_fs.existsSync.mockReturnValue(false);
|
|
51
|
-
const result = (0, _configFileNameProvider.getUATFileName)(mockStage, mockMode);
|
|
52
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(nonExistingPath);
|
|
53
|
-
expect(result).toBe(expectedDefaultPath);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('getEnvConfigFilePath', () => {
|
|
57
|
-
beforeEach(() => {
|
|
58
|
-
jest.clearAllMocks();
|
|
59
|
-
_path.default.resolve.mockImplementation((...segments) => segments.join('/'));
|
|
60
|
-
});
|
|
61
|
-
test('should return conf file path when file exists', () => {
|
|
62
|
-
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
63
|
-
_fs.existsSync.mockReturnValue(true);
|
|
64
|
-
const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'cd');
|
|
65
|
-
expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith('uat');
|
|
66
|
-
expect(_fs.existsSync).toHaveBeenCalled();
|
|
67
|
-
expect(result).toBe('uat/conf/cd/settings.json');
|
|
22
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(mockPath);
|
|
23
|
+
expect(result).toBe(mockPath);
|
|
68
24
|
});
|
|
69
|
-
test('
|
|
70
|
-
|
|
25
|
+
test('return the default config files for pipeline matched files not exists', () => {
|
|
26
|
+
const mode = 'ci';
|
|
27
|
+
const defaultPath = `${mockCwd}/uat/conf/default/uat.config.js`;
|
|
71
28
|
_fs.existsSync.mockReturnValue(false);
|
|
72
|
-
|
|
73
|
-
|
|
29
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
30
|
+
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
31
|
+
expect(_fs.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/${mode}/uat.config.js`);
|
|
32
|
+
expect(result).toBe(defaultPath);
|
|
74
33
|
});
|
|
75
34
|
});
|
|
@@ -1,83 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _fs =
|
|
4
|
+
var _fs = require("fs");
|
|
5
5
|
var _path = _interopRequireDefault(require("path"));
|
|
6
|
-
var _getUsers = require("../../../../../core/playwright/helpers/auth/getUsers");
|
|
7
|
-
var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
|
|
8
6
|
jest.mock('fs');
|
|
9
7
|
jest.mock('path');
|
|
10
|
-
jest.mock('../../../../../core/playwright/
|
|
11
|
-
|
|
8
|
+
jest.mock('../../../../../core/playwright/readConfigFile', () => ({
|
|
9
|
+
generateConfigFromFile: jest.fn(() => ({
|
|
10
|
+
uatDirectory: '/test/directory'
|
|
11
|
+
})),
|
|
12
|
+
getRunMode: jest.fn(() => 'dev')
|
|
12
13
|
}));
|
|
14
|
+
const {
|
|
15
|
+
getListOfActors
|
|
16
|
+
} = require('../../../../../core/playwright/helpers/auth/getUsers');
|
|
13
17
|
describe('getListOfActors', () => {
|
|
14
|
-
const stageConfig = 'uat/conf';
|
|
15
|
-
const mode = 'dev';
|
|
16
|
-
const stage = 'uat';
|
|
17
18
|
beforeEach(() => {
|
|
18
19
|
jest.clearAllMocks();
|
|
19
20
|
_path.default.join.mockImplementation((...args) => args.join('/'));
|
|
20
|
-
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
21
|
-
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
22
21
|
});
|
|
23
22
|
test('throws an error when config file cannot be loaded', () => {
|
|
24
|
-
_fs.
|
|
25
|
-
|
|
23
|
+
_fs.existsSync.mockReturnValueOnce(true); // Main config file exists
|
|
24
|
+
|
|
25
|
+
jest.mock('/test/directory/conf/dev/actors/index.js', () => {
|
|
26
26
|
throw new Error('Loading error');
|
|
27
27
|
}, {
|
|
28
28
|
virtual: true
|
|
29
29
|
});
|
|
30
|
-
expect(() =>
|
|
30
|
+
expect(() => getListOfActors()).toThrow('Error loading actor configuration from /test/directory/conf/dev/actors/index.js');
|
|
31
31
|
});
|
|
32
32
|
test('throws an error when beta feature config does not exist', () => {
|
|
33
|
-
_fs.
|
|
33
|
+
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
34
34
|
.mockReturnValueOnce(false); // Beta feature config does not exist in either path
|
|
35
35
|
|
|
36
36
|
const betaFeature = 'nonExistentFeature';
|
|
37
|
-
expect(() =>
|
|
37
|
+
expect(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
|
|
38
38
|
});
|
|
39
|
-
test('loads main configuration when betaFeature is not provided and main config exists', () => {
|
|
40
|
-
_fs.
|
|
41
|
-
|
|
42
|
-
jest.doMock(file, () => ({
|
|
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', () => ({
|
|
43
42
|
actors: []
|
|
44
43
|
}), {
|
|
45
44
|
virtual: true
|
|
46
45
|
});
|
|
47
|
-
const result =
|
|
46
|
+
const result = getListOfActors();
|
|
48
47
|
expect(result).toEqual({
|
|
49
48
|
actors: []
|
|
50
49
|
});
|
|
51
50
|
});
|
|
52
51
|
test('falls back to default configuration if main config file does not exist', () => {
|
|
53
|
-
_fs.
|
|
54
|
-
.
|
|
55
|
-
|
|
56
|
-
const defaultConfigFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/actors/index.js`));
|
|
57
|
-
jest.doMock(defaultConfigFile, () => ({
|
|
52
|
+
_fs.existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
|
|
53
|
+
jest.doMock('/test/directory/conf/default/actors/index.js', () => ({
|
|
58
54
|
actors: []
|
|
59
55
|
}), {
|
|
60
56
|
virtual: true
|
|
61
57
|
});
|
|
62
|
-
const result =
|
|
58
|
+
const result = getListOfActors();
|
|
63
59
|
expect(result).toEqual({
|
|
64
60
|
actors: []
|
|
65
61
|
});
|
|
66
62
|
});
|
|
67
63
|
test('loads beta feature configuration when betaFeature is provided', () => {
|
|
68
|
-
_fs.
|
|
64
|
+
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
69
65
|
.mockReturnValueOnce(true); // Beta feature config exists
|
|
70
66
|
|
|
71
67
|
const betaFeature = 'parentchild';
|
|
72
|
-
const betaFeaturePath =
|
|
68
|
+
const betaFeaturePath = `/test/directory/conf/dev/actors/beta/${betaFeature}/index.js`;
|
|
73
69
|
jest.doMock(betaFeaturePath, () => ({
|
|
74
70
|
betaActors: []
|
|
75
71
|
}), {
|
|
76
72
|
virtual: true
|
|
77
73
|
});
|
|
78
|
-
const result =
|
|
74
|
+
const result = getListOfActors(betaFeature);
|
|
79
75
|
expect(result).toEqual({
|
|
80
76
|
betaActors: []
|
|
81
77
|
});
|
|
78
|
+
expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
|
|
82
79
|
});
|
|
83
80
|
});
|
|
@@ -7,14 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.copyCommonSpecs = copyCommonSpecs;
|
|
8
8
|
var _fileUtils = require("./fileUtils");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _configConstants = _interopRequireDefault(require("../core/playwright/constants/configConstants"));
|
|
11
|
-
var _ConfigurationHelper = require("../core/playwright/configuration/ConfigurationHelper");
|
|
12
|
-
const stage = (0, _ConfigurationHelper.getRunStage)();
|
|
13
10
|
function copyCommonSpecs() {
|
|
14
11
|
const libraryPath = require.resolve("@zohodesk/testinglibrary");
|
|
15
12
|
// libraryPath will be build/index.js to go to the common specs we need to go one level up
|
|
16
13
|
const commonSpecPath = _path.default.resolve(libraryPath, '../', 'common');
|
|
17
|
-
const destDirectory = _path.default.resolve(process.cwd(),
|
|
14
|
+
const destDirectory = _path.default.resolve(process.cwd(), 'uat', 'modules', '.testingLib-common');
|
|
18
15
|
(0, _fileUtils.deleteFolder)(destDirectory);
|
|
19
16
|
(0, _fileUtils.copyDirectory)(commonSpecPath, destDirectory);
|
|
20
17
|
}
|