@zohodesk/testinglibrary 0.0.2 → 0.0.3
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/changelog.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { existsSync } = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const fileName = '
|
|
4
|
+
const fileName = 'uat.config.js';
|
|
5
5
|
|
|
6
6
|
function generateConfigFromFile() {
|
|
7
7
|
const filePath = path.resolve(process.cwd(), fileName);
|
|
@@ -14,5 +14,17 @@ function generateConfigFromFile() {
|
|
|
14
14
|
return {};
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function isUserConfigFileAvailable() {
|
|
18
|
+
const filePath = path.resolve(process.cwd(), fileName);
|
|
19
|
+
if (existsSync(filePath)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
|
|
18
|
-
module.exports =
|
|
26
|
+
module.exports = {
|
|
27
|
+
fileName,
|
|
28
|
+
isUserConfigFileAvailable,
|
|
29
|
+
generateConfigFromFile
|
|
30
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { defineConfig, devices } = require('@playwright/test');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { generateConfigFromFile } = require('../readConfigFile');
|
|
5
|
+
const numCPUs = require('os').cpus().length;
|
|
6
|
+
|
|
7
|
+
const defaultBrowser = ['Chrome']
|
|
8
|
+
|
|
9
|
+
const { browsers = defaultBrowser, isAuthMode, trace = false, video = false } = generateConfigFromFile();
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
let projects = browsers.map(browser => {
|
|
13
|
+
if (browser === 'Chrome') {
|
|
14
|
+
return {
|
|
15
|
+
name: 'chromium',
|
|
16
|
+
use: {
|
|
17
|
+
...devices['Desktop Chrome'],
|
|
18
|
+
storageState: isAuthMode ? path.resolve(process.cwd(), 'playwright/.auth/user.json') : null
|
|
19
|
+
},
|
|
20
|
+
dependencies: isAuthMode ? ['setup'] : [],
|
|
21
|
+
};
|
|
22
|
+
} else if (browser === 'Firefox') {
|
|
23
|
+
return {
|
|
24
|
+
name: 'firefox',
|
|
25
|
+
timeout: 4 * 60 * 1000,
|
|
26
|
+
expect: {
|
|
27
|
+
timeout: 80 * 1000,
|
|
28
|
+
},
|
|
29
|
+
use: {
|
|
30
|
+
...devices['Desktop Firefox'],
|
|
31
|
+
storageState: isAuthMode ? path.resolve(process.cwd(), 'playwright/.auth/user.json') : null
|
|
32
|
+
},
|
|
33
|
+
dependencies: isAuthMode ? ['setup'] : [],
|
|
34
|
+
};
|
|
35
|
+
} else if (browser === 'safari') {
|
|
36
|
+
return {
|
|
37
|
+
name: 'webkit',
|
|
38
|
+
timeout: 2 * 60 * 1000,
|
|
39
|
+
expect: {
|
|
40
|
+
timeout: 80 * 1000,
|
|
41
|
+
},
|
|
42
|
+
use: {
|
|
43
|
+
...devices['Desktop Safari'],
|
|
44
|
+
storageState: isAuthMode ? path.resolve(process.cwd(), 'playwright/.auth/user.json') : null
|
|
45
|
+
},
|
|
46
|
+
dependencies: isAuthMode ? ['setup'] : null,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}).filter(Boolean);
|
|
50
|
+
|
|
51
|
+
console.log(projects);
|
|
52
|
+
|
|
53
|
+
module.exports = defineConfig({
|
|
54
|
+
testDir: path.join(path.resolve(process.cwd()), 'uat'),
|
|
55
|
+
outputDir: path.join(process.cwd(), 'test-results'),
|
|
56
|
+
fullyParallel: true,
|
|
57
|
+
forbidOnly: !!process.env.CI,
|
|
58
|
+
retries: process.env.CI ? 2 : 0,
|
|
59
|
+
workers: process.env.CI ? 1 : 1,
|
|
60
|
+
reporter: [['html', { outputFolder: path.join(process.cwd(), 'playwright-report'), open: "always" }]],
|
|
61
|
+
timeout: 60 * 1000,
|
|
62
|
+
expect: {
|
|
63
|
+
timeout: 5 * 1000,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
use: {
|
|
67
|
+
trace: trace ? 'on' : 'off',
|
|
68
|
+
video: video ? {
|
|
69
|
+
mode: 'on',
|
|
70
|
+
size: { width: 640, height: 480 }
|
|
71
|
+
} : 'off'
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
projects: isAuthMode ? [
|
|
75
|
+
{ name: 'setup', testMatch: /.*\.setup\.js/ },
|
|
76
|
+
...projects
|
|
77
|
+
] : [...projects]
|
|
78
|
+
});
|
|
79
|
+
|
|
@@ -4,8 +4,7 @@ const { CUSTOM_COMMANDS } = require('./custom-commands');
|
|
|
4
4
|
const { cliArgsToObject, objectToCliArgs } = require('../../utils/cliArgsToObject');
|
|
5
5
|
const { initializeEnvConfig } = require('./env-initializer');
|
|
6
6
|
const { Logger } = require('../../utils/logger');
|
|
7
|
-
const
|
|
8
|
-
const generateConfigFromFile = require('./readConfigFile');
|
|
7
|
+
const { isUserConfigFileAvailable } = require('./readConfigFile');
|
|
9
8
|
const { getExecutableBinaryPath } = require('../../utils/rootPath');
|
|
10
9
|
|
|
11
10
|
|
|
@@ -15,11 +14,9 @@ const userArgs = process.argv.slice(2);
|
|
|
15
14
|
|
|
16
15
|
const userArgsObject = cliArgsToObject(userArgs);
|
|
17
16
|
|
|
18
|
-
initializeEnvConfig(userArgsObject.mode ? userArgsObject.mode : 'dev');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
generateConfigFromFile();
|
|
22
17
|
|
|
18
|
+
// Environment variables Initialization
|
|
19
|
+
initializeEnvConfig(userArgsObject.mode ? userArgsObject.mode : 'dev');
|
|
23
20
|
|
|
24
21
|
|
|
25
22
|
const playwrightArgs = objectToCliArgs(userArgsObject, (key) => !CUSTOM_COMMANDS.includes(key));
|
|
@@ -28,7 +25,10 @@ const playwrightArgs = objectToCliArgs(userArgsObject, (key) => !CUSTOM_COMMANDS
|
|
|
28
25
|
const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));
|
|
29
26
|
|
|
30
27
|
const command = playwrightPath;
|
|
31
|
-
|
|
28
|
+
|
|
29
|
+
const configPath = isUserConfigFileAvailable() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
30
|
+
|
|
31
|
+
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
function createTestRunner() {
|