@zohodesk/testinglibrary 0.0.1 → 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/README.md +17 -17
- package/bin/cli.js +1 -1
- package/bin/postinstall.js +15 -15
- package/changelog.md +15 -0
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +5772 -0
- package/package.json +31 -31
- package/playwright.config.js +112 -112
- package/src/core/jest/preprocessor/jsPreprocessor.js +9 -9
- package/src/core/jest/runner/jest-runner.js +44 -45
- package/src/core/jest/setup/index.js +165 -165
- package/src/core/playwright/codegen.js +60 -61
- package/src/core/playwright/custom-commands.js +2 -2
- package/src/core/playwright/env-initializer.js +23 -23
- package/src/core/playwright/index.js +81 -80
- package/src/core/playwright/readConfigFile.js +30 -18
- package/src/core/playwright/report-generator.js +42 -43
- package/src/core/playwright/setup/config-creator.js +79 -0
- package/src/core/playwright/test-runner.js +64 -64
- package/src/index.js +8 -8
- package/src/lib/cli.js +34 -34
- package/src/utils/cliArgsToObject.js +34 -34
- package/src/utils/getFilePath.js +8 -8
- package/src/utils/logger.js +27 -27
- package/src/utils/rootPath.js +50 -18
|
@@ -1,81 +1,82 @@
|
|
|
1
|
-
const { expect, test: base } = require('@playwright/test');
|
|
2
|
-
// function test(descrition, callback) {
|
|
3
|
-
// return test(descrition, ({ page }) => {
|
|
4
|
-
// const { locator, ...custompage } = page
|
|
5
|
-
// callback({ page: custompage })
|
|
6
|
-
// })
|
|
7
|
-
// }
|
|
8
|
-
|
|
9
|
-
// class FilteredPage {
|
|
10
|
-
// constructor(page) {
|
|
11
|
-
// this.page = page;
|
|
12
|
-
// this.allowedMethods = ['getByText', 'getByTitle'];
|
|
13
|
-
// this.context = page.context;
|
|
14
|
-
// }
|
|
15
|
-
|
|
16
|
-
// goto(...args) {
|
|
17
|
-
// return this.page['goto'](...args);
|
|
18
|
-
// }
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// getByRole(...args) {
|
|
22
|
-
// return this.page['getByRole'](...args);
|
|
23
|
-
// }
|
|
24
|
-
// }
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// function FilteredPage(page) {
|
|
28
|
-
// return {
|
|
29
|
-
// getByRole: () => {
|
|
30
|
-
// throw new Error('You cannnot use getByRole property')
|
|
31
|
-
// }
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
|
|
35
|
-
const test = base.extend({
|
|
36
|
-
page: async ({ baseURL, page }, use) => {
|
|
37
|
-
// const proxyPage = new Proxy(page, {
|
|
38
|
-
// get: function (obj, prop) {
|
|
39
|
-
// console.log('Gettig Priop', prop);
|
|
40
|
-
// let filterMethod = FilteredPage(page)[prop];
|
|
41
|
-
// if (filterMethod) {
|
|
42
|
-
// return filterMethod;
|
|
43
|
-
// } else {
|
|
44
|
-
// return obj[prop] ? obj[prop] : 'property does not exist';
|
|
45
|
-
// }
|
|
46
|
-
// }
|
|
47
|
-
// })
|
|
48
|
-
page.getBaseUrl = function () {
|
|
49
|
-
if (process.env.mode === 'dev') {
|
|
50
|
-
return `${process.env.domain}?devURL=${process.env.devUrl}`;
|
|
51
|
-
}
|
|
52
|
-
return `${process.env.domain}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
page.getCustomPageUrl = function (url) {
|
|
56
|
-
if (process.env.mode === 'dev') {
|
|
57
|
-
return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`
|
|
58
|
-
}
|
|
59
|
-
return `${process.env.domain}/${url}`
|
|
60
|
-
}
|
|
61
|
-
await use(page);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//await use(new FilteredPage(page));
|
|
65
|
-
|
|
66
|
-
// await use(async (page) => {
|
|
67
|
-
// delete page.getByTestId;
|
|
68
|
-
// await page;
|
|
69
|
-
// });
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
context: async ({ context }, use) => {
|
|
73
|
-
await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
|
|
74
|
-
await use(context);
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
const { expect, test: base } = require('@playwright/test');
|
|
2
|
+
// function test(descrition, callback) {
|
|
3
|
+
// return test(descrition, ({ page }) => {
|
|
4
|
+
// const { locator, ...custompage } = page
|
|
5
|
+
// callback({ page: custompage })
|
|
6
|
+
// })
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
// class FilteredPage {
|
|
10
|
+
// constructor(page) {
|
|
11
|
+
// this.page = page;
|
|
12
|
+
// this.allowedMethods = ['getByText', 'getByTitle'];
|
|
13
|
+
// this.context = page.context;
|
|
14
|
+
// }
|
|
15
|
+
|
|
16
|
+
// goto(...args) {
|
|
17
|
+
// return this.page['goto'](...args);
|
|
18
|
+
// }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// getByRole(...args) {
|
|
22
|
+
// return this.page['getByRole'](...args);
|
|
23
|
+
// }
|
|
24
|
+
// }
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// function FilteredPage(page) {
|
|
28
|
+
// return {
|
|
29
|
+
// getByRole: () => {
|
|
30
|
+
// throw new Error('You cannnot use getByRole property')
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
const test = base.extend({
|
|
36
|
+
page: async ({ baseURL, page }, use) => {
|
|
37
|
+
// const proxyPage = new Proxy(page, {
|
|
38
|
+
// get: function (obj, prop) {
|
|
39
|
+
// console.log('Gettig Priop', prop);
|
|
40
|
+
// let filterMethod = FilteredPage(page)[prop];
|
|
41
|
+
// if (filterMethod) {
|
|
42
|
+
// return filterMethod;
|
|
43
|
+
// } else {
|
|
44
|
+
// return obj[prop] ? obj[prop] : 'property does not exist';
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
// })
|
|
48
|
+
page.getBaseUrl = function () {
|
|
49
|
+
if (process.env.mode === 'dev') {
|
|
50
|
+
return `${process.env.domain}?devURL=${process.env.devUrl}`;
|
|
51
|
+
}
|
|
52
|
+
return `${process.env.domain}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
page.getCustomPageUrl = function (url) {
|
|
56
|
+
if (process.env.mode === 'dev') {
|
|
57
|
+
return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`
|
|
58
|
+
}
|
|
59
|
+
return `${process.env.domain}/${url}`
|
|
60
|
+
}
|
|
61
|
+
await use(page);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
//await use(new FilteredPage(page));
|
|
65
|
+
|
|
66
|
+
// await use(async (page) => {
|
|
67
|
+
// delete page.getByTestId;
|
|
68
|
+
// await page;
|
|
69
|
+
// });
|
|
70
|
+
|
|
71
|
+
},
|
|
72
|
+
context: async ({ context }, use) => {
|
|
73
|
+
await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
|
|
74
|
+
await use(context);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
expect,
|
|
81
|
+
test
|
|
81
82
|
}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
const { existsSync } = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const fileName = '
|
|
5
|
-
|
|
6
|
-
function generateConfigFromFile() {
|
|
7
|
-
const filePath = path.resolve(process.cwd(), fileName);
|
|
8
|
-
|
|
9
|
-
if (existsSync(filePath)) {
|
|
10
|
-
const config = require(filePath);
|
|
11
|
-
return config;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
const { existsSync } = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const fileName = 'uat.config.js';
|
|
5
|
+
|
|
6
|
+
function generateConfigFromFile() {
|
|
7
|
+
const filePath = path.resolve(process.cwd(), fileName);
|
|
8
|
+
|
|
9
|
+
if (existsSync(filePath)) {
|
|
10
|
+
const config = require(filePath);
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
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
|
+
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
fileName,
|
|
28
|
+
isUserConfigFileAvailable,
|
|
29
|
+
generateConfigFromFile
|
|
30
|
+
};
|
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { Logger } = require('../../utils/logger');
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
const { spawn } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { Logger } = require('../../utils/logger');
|
|
4
|
+
const { getExecutableBinaryPath } = require('../../utils/rootPath');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const userArgs = process.argv.slice(3);
|
|
8
|
+
|
|
9
|
+
const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));;
|
|
10
|
+
const command = playwrightPath;
|
|
11
|
+
const reportPath = path.resolve(process.cwd(), './playwright-report');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const args = ['show-report', reportPath].concat(userArgs);
|
|
15
|
+
|
|
16
|
+
function generateReport() {
|
|
17
|
+
const childProcess = spawn(command, args, { stdio: 'inherit' });
|
|
18
|
+
childProcess.on('error', (error) => {
|
|
19
|
+
Logger.log(Logger.FAILURE_TYPE, error);
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
childProcess.on('exit', (code, signal) => {
|
|
23
|
+
Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
24
|
+
|
|
25
|
+
process.exit();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
process.on('exit', () => {
|
|
29
|
+
Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
30
|
+
childProcess.kill();
|
|
31
|
+
return;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
process.on('SIGINT', () => {
|
|
35
|
+
Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
|
|
36
|
+
childProcess.kill();
|
|
37
|
+
process.exit();
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
44
43
|
module.exports = generateReport;
|
|
@@ -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
|
+
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { CUSTOM_COMMANDS } = require('./custom-commands');
|
|
4
|
-
const { cliArgsToObject, objectToCliArgs } = require('../../utils/cliArgsToObject');
|
|
5
|
-
const { initializeEnvConfig } = require('./env-initializer');
|
|
6
|
-
const { Logger } = require('../../utils/logger');
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const args = ['test', '--config',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function createTestRunner() {
|
|
35
|
-
// Spawn the child process
|
|
36
|
-
|
|
37
|
-
const childProcess = spawn(command, args, { stdio: 'inherit' });
|
|
38
|
-
|
|
39
|
-
childProcess.on('error', (error) => {
|
|
40
|
-
Logger.log(Logger.FAILURE_TYPE, error);
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
childProcess.on('exit', (code, signal) => {
|
|
44
|
-
Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
45
|
-
|
|
46
|
-
process.exit();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
process.on('exit', () => {
|
|
50
|
-
Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
51
|
-
//childProcess.kill();
|
|
52
|
-
return;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
process.on('SIGINT', () => {
|
|
56
|
-
Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
|
|
57
|
-
//childProcess.kill();
|
|
58
|
-
process.exit();
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
module.exports = createTestRunner;
|
|
1
|
+
const { spawn } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { CUSTOM_COMMANDS } = require('./custom-commands');
|
|
4
|
+
const { cliArgsToObject, objectToCliArgs } = require('../../utils/cliArgsToObject');
|
|
5
|
+
const { initializeEnvConfig } = require('./env-initializer');
|
|
6
|
+
const { Logger } = require('../../utils/logger');
|
|
7
|
+
const { isUserConfigFileAvailable } = require('./readConfigFile');
|
|
8
|
+
const { getExecutableBinaryPath } = require('../../utils/rootPath');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// Access the command line arguments
|
|
13
|
+
const userArgs = process.argv.slice(2);
|
|
14
|
+
|
|
15
|
+
const userArgsObject = cliArgsToObject(userArgs);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// Environment variables Initialization
|
|
19
|
+
initializeEnvConfig(userArgsObject.mode ? userArgsObject.mode : 'dev');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const playwrightArgs = objectToCliArgs(userArgsObject, (key) => !CUSTOM_COMMANDS.includes(key));
|
|
23
|
+
|
|
24
|
+
// Command and arguments for npx playwright test
|
|
25
|
+
const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));
|
|
26
|
+
|
|
27
|
+
const command = playwrightPath;
|
|
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
|
+
|
|
33
|
+
|
|
34
|
+
function createTestRunner() {
|
|
35
|
+
// Spawn the child process
|
|
36
|
+
|
|
37
|
+
const childProcess = spawn(command, args, { stdio: 'inherit' });
|
|
38
|
+
|
|
39
|
+
childProcess.on('error', (error) => {
|
|
40
|
+
Logger.log(Logger.FAILURE_TYPE, error);
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
childProcess.on('exit', (code, signal) => {
|
|
44
|
+
Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
45
|
+
|
|
46
|
+
process.exit();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
process.on('exit', () => {
|
|
50
|
+
Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
51
|
+
//childProcess.kill();
|
|
52
|
+
return;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
process.on('SIGINT', () => {
|
|
56
|
+
Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
|
|
57
|
+
//childProcess.kill();
|
|
58
|
+
process.exit();
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
module.exports = createTestRunner;
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const { expect, test } = require('./core/playwright/index');
|
|
2
|
-
const { fireEvent, render } = require('@testing-library/react');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
expect,
|
|
6
|
-
test,
|
|
7
|
-
fireEvent,
|
|
8
|
-
render
|
|
1
|
+
const { expect, test } = require('./core/playwright/index');
|
|
2
|
+
const { fireEvent, render } = require('@testing-library/react');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
expect,
|
|
6
|
+
test,
|
|
7
|
+
fireEvent,
|
|
8
|
+
render
|
|
9
9
|
}
|
package/src/lib/cli.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
const createTestRunner = require("../core/playwright/test-runner");
|
|
2
|
-
const createJestRunner = require('../core/jest/runner/jest-runner');
|
|
3
|
-
const generateReport = require("../core/playwright/report-generator");
|
|
4
|
-
const generateCodegen = require('../core/playwright/codegen')
|
|
5
|
-
const { Logger } = require("../utils/logger");
|
|
6
|
-
|
|
7
|
-
const [, , option] = process.argv;
|
|
8
|
-
const args = process.argv.slice(3);
|
|
9
|
-
const appPath = process.cwd();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
switch (option) {
|
|
13
|
-
case 'test': {
|
|
14
|
-
Logger.log(Logger.SUCCESS_TYPE, 'Running Tests..');
|
|
15
|
-
createTestRunner();
|
|
16
|
-
//createJestRunner();
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
case 'report': {
|
|
20
|
-
// console.log('\x1b[36mGenerating Reports...\x1b[0m');
|
|
21
|
-
Logger.log(Logger.SUCCESS_TYPE, 'Generating Reports...');
|
|
22
|
-
generateReport();
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
case 'codegen': {
|
|
26
|
-
Logger.log(Logger.INFO_TYPE, 'The purpose of codegen is to assist developer .....')
|
|
27
|
-
generateCodegen();
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
default: {
|
|
32
|
-
console.log('Supported Commands test and report')
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
1
|
+
const createTestRunner = require("../core/playwright/test-runner");
|
|
2
|
+
const createJestRunner = require('../core/jest/runner/jest-runner');
|
|
3
|
+
const generateReport = require("../core/playwright/report-generator");
|
|
4
|
+
const generateCodegen = require('../core/playwright/codegen')
|
|
5
|
+
const { Logger } = require("../utils/logger");
|
|
6
|
+
|
|
7
|
+
const [, , option] = process.argv;
|
|
8
|
+
const args = process.argv.slice(3);
|
|
9
|
+
const appPath = process.cwd();
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
switch (option) {
|
|
13
|
+
case 'test': {
|
|
14
|
+
Logger.log(Logger.SUCCESS_TYPE, 'Running Tests..');
|
|
15
|
+
createTestRunner();
|
|
16
|
+
//createJestRunner();
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
case 'report': {
|
|
20
|
+
// console.log('\x1b[36mGenerating Reports...\x1b[0m');
|
|
21
|
+
Logger.log(Logger.SUCCESS_TYPE, 'Generating Reports...');
|
|
22
|
+
generateReport();
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case 'codegen': {
|
|
26
|
+
Logger.log(Logger.INFO_TYPE, 'The purpose of codegen is to assist developer .....')
|
|
27
|
+
generateCodegen();
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
default: {
|
|
32
|
+
console.log('Supported Commands test and report')
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
35
|
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
|
|
2
|
-
const processEnv = {};
|
|
3
|
-
cliArgs.forEach(option => {
|
|
4
|
-
if (/^--./.test(option)) {
|
|
5
|
-
const equIndex = option.indexOf('=');
|
|
6
|
-
let key = option.slice(2, equIndex);
|
|
7
|
-
let value = option.slice(equIndex + 1);
|
|
8
|
-
if (equIndex === -1) {
|
|
9
|
-
key = option.slice(2);
|
|
10
|
-
value = true;
|
|
11
|
-
}
|
|
12
|
-
processEnv[key] = value;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return processEnv;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function objectToCliArgs(objectToBeConverted, isKeyNeedToBeAdded) {
|
|
19
|
-
const argsArray = [];
|
|
20
|
-
|
|
21
|
-
Object.keys(objectToBeConverted).forEach(key => {
|
|
22
|
-
if (isKeyNeedToBeAdded(key)) {
|
|
23
|
-
if (typeof objectToBeConverted[key] === 'boolean' && objectToBeConverted[key]) {
|
|
24
|
-
argsArray.push(`--${key}`)
|
|
25
|
-
} else {
|
|
26
|
-
argsArray.push(`--${key}=${objectToBeConverted[key]}`)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return argsArray;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
|
|
2
|
+
const processEnv = {};
|
|
3
|
+
cliArgs.forEach(option => {
|
|
4
|
+
if (/^--./.test(option)) {
|
|
5
|
+
const equIndex = option.indexOf('=');
|
|
6
|
+
let key = option.slice(2, equIndex);
|
|
7
|
+
let value = option.slice(equIndex + 1);
|
|
8
|
+
if (equIndex === -1) {
|
|
9
|
+
key = option.slice(2);
|
|
10
|
+
value = true;
|
|
11
|
+
}
|
|
12
|
+
processEnv[key] = value;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return processEnv;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function objectToCliArgs(objectToBeConverted, isKeyNeedToBeAdded) {
|
|
19
|
+
const argsArray = [];
|
|
20
|
+
|
|
21
|
+
Object.keys(objectToBeConverted).forEach(key => {
|
|
22
|
+
if (isKeyNeedToBeAdded(key)) {
|
|
23
|
+
if (typeof objectToBeConverted[key] === 'boolean' && objectToBeConverted[key]) {
|
|
24
|
+
argsArray.push(`--${key}`)
|
|
25
|
+
} else {
|
|
26
|
+
argsArray.push(`--${key}=${objectToBeConverted[key]}`)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return argsArray;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
35
|
module.exports = { cliArgsToObject, objectToCliArgs };
|