@zohodesk/testinglibrary 0.1.3 → 0.1.4

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.
@@ -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 !== null) {
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,
@@ -52,16 +65,7 @@ function getPlaywrightConfig() {
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
  }
@@ -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
  /**
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {