@zohodesk/testinglibrary 3.2.14 → 4.0.0
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 +18 -8
- package/build/core/jest/setup/index.js +1 -1
- package/build/core/playwright/configuration/ConfigurationHelper.js +7 -5
- package/build/core/playwright/constants/configConstants.js +17 -0
- package/build/core/playwright/constants/reporterConstants.js +11 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +10 -9
- package/build/core/playwright/helpers/auth/getUsers.js +14 -14
- package/build/core/playwright/helpers/configFileNameProvider.js +15 -8
- package/build/core/playwright/helpers/configPathResolver.js +38 -0
- package/build/core/playwright/readConfigFile.js +3 -2
- package/build/core/playwright/reporter/helpers/mergeAbortedTests.js +78 -0
- package/build/core/playwright/setup/custom-reporter.js +3 -0
- package/build/core/playwright/test-runner.js +4 -2
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +54 -13
- package/build/test/core/playwright/helpers/__tests__/configPathResolver.test.js +55 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +29 -26
- package/build/utils/fileUtils.js +1 -1
- package/build/utils/logger.js +1 -1
- package/npm-shrinkwrap.json +2706 -3546
- package/package.json +25 -25
- package/build/test/Test.js +0 -13
|
@@ -1,80 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _fs = require("fs");
|
|
4
|
+
var _fs = _interopRequireDefault(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");
|
|
6
8
|
jest.mock('fs');
|
|
7
9
|
jest.mock('path');
|
|
8
|
-
jest.mock('../../../../../core/playwright/
|
|
9
|
-
|
|
10
|
-
uatDirectory: '/test/directory'
|
|
11
|
-
})),
|
|
12
|
-
getRunMode: jest.fn(() => 'dev')
|
|
10
|
+
jest.mock('../../../../../core/playwright/helpers/configPathResolver', () => ({
|
|
11
|
+
getConfigPath: jest.fn()
|
|
13
12
|
}));
|
|
14
|
-
const {
|
|
15
|
-
getListOfActors
|
|
16
|
-
} = require('../../../../../core/playwright/helpers/auth/getUsers');
|
|
17
13
|
describe('getListOfActors', () => {
|
|
14
|
+
const stageConfig = 'uat/conf';
|
|
15
|
+
const mode = 'dev';
|
|
16
|
+
const stage = 'uat';
|
|
18
17
|
beforeEach(() => {
|
|
19
18
|
jest.clearAllMocks();
|
|
20
19
|
_path.default.join.mockImplementation((...args) => args.join('/'));
|
|
20
|
+
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
21
|
+
_configPathResolver.getConfigPath.mockReturnValue('uat/conf');
|
|
21
22
|
});
|
|
22
23
|
test('throws an error when config file cannot be loaded', () => {
|
|
23
|
-
_fs.existsSync.mockReturnValueOnce(true);
|
|
24
|
-
|
|
25
|
-
jest.mock('/test/directory/conf/dev/actors/index.js', () => {
|
|
24
|
+
_fs.default.existsSync.mockReturnValueOnce(true);
|
|
25
|
+
jest.mock('/uat/conf/dev/actors/index.js', () => {
|
|
26
26
|
throw new Error('Loading error');
|
|
27
27
|
}, {
|
|
28
28
|
virtual: true
|
|
29
29
|
});
|
|
30
|
-
expect(() => getListOfActors()).toThrow(
|
|
30
|
+
expect(() => (0, _getUsers.getListOfActors)()).toThrow(`Error loading actor configuration from ${_path.default.join(_path.default.resolve(process.cwd(), 'uat/conf/dev/actors/index.js'))}`);
|
|
31
31
|
});
|
|
32
32
|
test('throws an error when beta feature config does not exist', () => {
|
|
33
|
-
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
33
|
+
_fs.default.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(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
|
|
37
|
+
expect(() => (0, _getUsers.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
|
|
40
|
-
_fs.existsSync.mockReturnValueOnce(true);
|
|
41
|
-
|
|
39
|
+
test('loads main configuration when betaFeature is not provided and main config exists', () => {
|
|
40
|
+
_fs.default.existsSync.mockReturnValueOnce(true);
|
|
41
|
+
const file = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/index.js`));
|
|
42
|
+
jest.doMock(file, () => ({
|
|
42
43
|
actors: []
|
|
43
44
|
}), {
|
|
44
45
|
virtual: true
|
|
45
46
|
});
|
|
46
|
-
const result = getListOfActors();
|
|
47
|
+
const result = (0, _getUsers.getListOfActors)();
|
|
47
48
|
expect(result).toEqual({
|
|
48
49
|
actors: []
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
52
|
test('falls back to default configuration if main config file does not exist', () => {
|
|
52
|
-
_fs.existsSync.mockReturnValueOnce(false)
|
|
53
|
-
|
|
53
|
+
_fs.default.existsSync.mockReturnValueOnce(false) // Main config file missing
|
|
54
|
+
.mockReturnValueOnce(true); // Beta feature config exists
|
|
55
|
+
|
|
56
|
+
const defaultConfigFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/actors/index.js`));
|
|
57
|
+
jest.doMock(defaultConfigFile, () => ({
|
|
54
58
|
actors: []
|
|
55
59
|
}), {
|
|
56
60
|
virtual: true
|
|
57
61
|
});
|
|
58
|
-
const result = getListOfActors();
|
|
62
|
+
const result = (0, _getUsers.getListOfActors)();
|
|
59
63
|
expect(result).toEqual({
|
|
60
64
|
actors: []
|
|
61
65
|
});
|
|
62
66
|
});
|
|
63
67
|
test('loads beta feature configuration when betaFeature is provided', () => {
|
|
64
|
-
_fs.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
68
|
+
_fs.default.existsSync.mockReturnValueOnce(true) // Main config file exists
|
|
65
69
|
.mockReturnValueOnce(true); // Beta feature config exists
|
|
66
70
|
|
|
67
71
|
const betaFeature = 'parentchild';
|
|
68
|
-
const betaFeaturePath =
|
|
72
|
+
const betaFeaturePath = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/beta/${betaFeature}/index.js`));
|
|
69
73
|
jest.doMock(betaFeaturePath, () => ({
|
|
70
74
|
betaActors: []
|
|
71
75
|
}), {
|
|
72
76
|
virtual: true
|
|
73
77
|
});
|
|
74
|
-
const result = getListOfActors(betaFeature);
|
|
78
|
+
const result = (0, _getUsers.getListOfActors)(betaFeature);
|
|
75
79
|
expect(result).toEqual({
|
|
76
80
|
betaActors: []
|
|
77
81
|
});
|
|
78
|
-
expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
|
|
79
82
|
});
|
|
80
83
|
});
|
package/build/utils/fileUtils.js
CHANGED
package/build/utils/logger.js
CHANGED
|
@@ -22,7 +22,7 @@ class LoggerImpl {
|
|
|
22
22
|
info() {}
|
|
23
23
|
log(type, message) {
|
|
24
24
|
const color = this.colors[type];
|
|
25
|
-
this.consoleLogger.log(`${color[0]}${message}${color[1]}`);
|
|
25
|
+
this.consoleLogger.log(`${color[0]}${message}${color[1]}\n`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
const Logger = exports.Logger = new LoggerImpl();
|