@zohodesk/testinglibrary 0.0.1-exp.1 → 0.0.1

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 CHANGED
@@ -1,18 +1,18 @@
1
- # Testing Framework
2
-
3
- ## Framework that abstracts the configuration for playwright and Jest
4
-
5
- - Playwright
6
- - Jest
7
-
8
- ## Cli
9
-
10
- ## Feature Supported
11
-
12
- ### Run TestCase
13
-
14
- - npm run test
15
- ### Generate Report
16
-
17
- - npm run report
1
+ # Testing Framework
2
+
3
+ ## Framework that abstracts the configuration for playwright and Jest
4
+
5
+ - Playwright
6
+ - Jest
7
+
8
+ ## Cli
9
+
10
+ ## Feature Supported
11
+
12
+ ### Run TestCase
13
+
14
+ - npm run test
15
+ ### Generate Report
16
+
17
+ - npm run report
18
18
 
package/bin/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
-
2
+
3
3
  require('../src/lib/cli');
@@ -1,16 +1,16 @@
1
- const path = require('path');
2
- const { spawn } = require('child_process');
3
- const { Logger } = require('../src/utils/logger');
4
- const getFilePathWithExtension = require('../src/utils/getFilePath');
5
-
6
- const playwrightPath = path.resolve('node_modules', '.bin', getFilePathWithExtension('playwright'));
7
- const command = playwrightPath;
8
- const args = ['install'];
9
-
10
- Logger.log(Logger.INFO_TYPE, 'Downloading browsers for running tests');
11
-
12
- const childProcess = spawn(command, args, { stdio: 'inherit' });
13
-
14
- childProcess.on('error', (error) => {
15
- Logger.log(Logger.FAILURE_TYPE, error);
1
+ const path = require('path');
2
+ const { spawn } = require('child_process');
3
+ const { Logger } = require('../src/utils/logger');
4
+ const getFilePathWithExtension = require('../src/utils/getFilePath');
5
+
6
+ const playwrightPath = path.resolve('node_modules', '.bin', getFilePathWithExtension('playwright'));
7
+ const command = playwrightPath;
8
+ const args = ['install'];
9
+
10
+ Logger.log(Logger.INFO_TYPE, 'Downloading browsers for running tests');
11
+
12
+ const childProcess = spawn(command, args, { stdio: 'inherit' });
13
+
14
+ childProcess.on('error', (error) => {
15
+ Logger.log(Logger.FAILURE_TYPE, error);
16
16
  });
package/jest.config.js CHANGED
@@ -1,64 +1,64 @@
1
- const path = require('path');
2
- const { existsSync } = require('fs');
3
- const appPath = process.cwd();
4
-
5
- const appGlobals = path.resolve(appPath, '__testUtils__', 'globals.js');
6
-
7
- module.exports = {
8
- rootDir: process.cwd(),
9
- testEnvironment: 'jsdom',
10
-
11
- setupFilesAfterEnv: [
12
- existsSync(appGlobals) && appGlobals,
13
- path.resolve(__dirname, 'src', 'core', 'jest', 'setup', 'index.js')
14
- ].filter(Boolean),
15
-
16
- transform: {
17
- '^.+\\.(js|jsx)$': path.resolve(
18
- __dirname,
19
- 'src',
20
- 'core',
21
- 'jest',
22
- 'preprocessor',
23
- 'jsPreprocessor.js'
24
- )
25
- },
26
-
27
- modulePathIgnorePatterns: ['/build/'],
28
-
29
- transformIgnorePatterns: [
30
- '/node_modules/(?!(@zohodesk)/)'
31
- ],
32
-
33
- testPathIgnorePatterns: [
34
- '/node_modules/',
35
- '/build/',
36
- '/uat/'
37
- ],
38
-
39
- watchPathIgnorePatterns: [
40
- '/node_modules/',
41
- '/build/'
42
- ],
43
-
44
- clearMocks: true,
45
- resetMocks: false,
46
-
47
- collectCoverage: true,
48
- collectCoverageFrom: ['src/**/*.js'],
49
- coverageDirectory: './build/cov',
50
- coverageReporters: ['lcov', 'json', 'html', 'json-summary', 'text'],
51
- coverageThreshold: {
52
- global: {
53
- branches: 100,
54
- functions: 100,
55
- lines: 100,
56
- statements: 100
57
- }
58
- },
59
- globals: {
60
- __DEVELOPMENT__: true,
61
- __DOCS__: false,
62
- __TEST__: true
63
- }
1
+ const path = require('path');
2
+ const { existsSync } = require('fs');
3
+ const appPath = process.cwd();
4
+
5
+ const appGlobals = path.resolve(appPath, '__testUtils__', 'globals.js');
6
+
7
+ module.exports = {
8
+ rootDir: process.cwd(),
9
+ testEnvironment: 'jsdom',
10
+
11
+ setupFilesAfterEnv: [
12
+ existsSync(appGlobals) && appGlobals,
13
+ path.resolve(__dirname, 'src', 'core', 'jest', 'setup', 'index.js')
14
+ ].filter(Boolean),
15
+
16
+ transform: {
17
+ '^.+\\.(js|jsx)$': path.resolve(
18
+ __dirname,
19
+ 'src',
20
+ 'core',
21
+ 'jest',
22
+ 'preprocessor',
23
+ 'jsPreprocessor.js'
24
+ )
25
+ },
26
+
27
+ modulePathIgnorePatterns: ['/build/'],
28
+
29
+ transformIgnorePatterns: [
30
+ '/node_modules/(?!(@zohodesk)/)'
31
+ ],
32
+
33
+ testPathIgnorePatterns: [
34
+ '/node_modules/',
35
+ '/build/',
36
+ '/uat/'
37
+ ],
38
+
39
+ watchPathIgnorePatterns: [
40
+ '/node_modules/',
41
+ '/build/'
42
+ ],
43
+
44
+ clearMocks: true,
45
+ resetMocks: false,
46
+
47
+ collectCoverage: true,
48
+ collectCoverageFrom: ['src/**/*.js'],
49
+ coverageDirectory: './build/cov',
50
+ coverageReporters: ['lcov', 'json', 'html', 'json-summary', 'text'],
51
+ coverageThreshold: {
52
+ global: {
53
+ branches: 100,
54
+ functions: 100,
55
+ lines: 100,
56
+ statements: 100
57
+ }
58
+ },
59
+ globals: {
60
+ __DEVELOPMENT__: true,
61
+ __DOCS__: false,
62
+ __TEST__: true
63
+ }
64
64
  };
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
- {
2
- "name": "@zohodesk/testinglibrary",
3
- "version": "0.0.1-exp.1",
4
- "description": "",
5
- "main": "./src/index.js",
6
- "scripts": {
7
- "postinstall": "node bin/postinstall.js",
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "keywords": [],
11
- "author": "",
12
- "license": "ISC",
13
- "dependencies": {
14
- "@babel/preset-env": "^7.22.9",
15
- "@babel/preset-react": "^7.22.5",
16
- "@playwright/test": "^1.37.1",
17
- "@testing-library/jest-dom": "^5.11.9",
18
- "@testing-library/react": "^11.2.7",
19
- "@testing-library/react-hooks": "^7.0.2",
20
- "babel-jest": "^29.6.2",
21
- "babel-plugin-transform-dynamic-import": "^2.1.0",
22
- "jest": "^29.6.2",
23
- "jest-environment-jsdom": "^29.6.2",
24
- "msw": "^1.2.3",
25
- "react": "16.13.1",
26
- "react-dom": "16.13.1"
27
- },
28
- "bin": {
29
- "ZDTestingFramework": "./bin/cli.js"
30
- }
31
- }
1
+ {
2
+ "name": "@zohodesk/testinglibrary",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "./src/index.js",
6
+ "scripts": {
7
+ "postinstall": "node bin/postinstall.js",
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "dependencies": {
14
+ "@babel/preset-env": "^7.22.9",
15
+ "@babel/preset-react": "^7.22.5",
16
+ "@playwright/test": "^1.37.1",
17
+ "@testing-library/jest-dom": "^5.11.9",
18
+ "@testing-library/react": "^11.2.7",
19
+ "@testing-library/react-hooks": "^7.0.2",
20
+ "babel-jest": "^29.6.2",
21
+ "babel-plugin-transform-dynamic-import": "^2.1.0",
22
+ "jest": "^29.6.2",
23
+ "jest-environment-jsdom": "^29.6.2",
24
+ "msw": "^1.2.3",
25
+ "react": "16.13.1",
26
+ "react-dom": "16.13.1"
27
+ },
28
+ "bin": {
29
+ "ZDTestingFramework": "./bin/cli.js"
30
+ }
31
+ }
@@ -1,112 +1,112 @@
1
- // @ts-check
2
- const { defineConfig, devices } = require('@playwright/test');
3
- const path = require('path');
4
- const numCPUs = require('os').cpus().length;
5
-
6
- /**
7
- * Read environment variables from file.
8
- * https://github.com/motdotla/dotenv
9
- */
10
- // require('dotenv').config();
11
-
12
- /**
13
- * @see https://playwright.dev/docs/test-configuration
14
- */
15
- module.exports = defineConfig({
16
- testDir: path.join(path.resolve(process.cwd()), 'uat'),
17
- outputDir: path.join(process.cwd(), 'test-results'),
18
- /* Run tests in files in parallel */
19
- fullyParallel: true,
20
- /* Fail the build on CI if you accidentally left test.only in the source code. */
21
- forbidOnly: !!process.env.CI,
22
- /* Retry on CI only */
23
- retries: process.env.CI ? 2 : 0,
24
- /* Opt out of parallel tests on CI. */
25
- workers: process.env.CI ? 1 : 1,
26
- /* Reporter to use. See https://playwright.dev/docs/test-reporters */
27
- reporter: [['html', { outputFolder: path.join(process.cwd(), 'playwright-report'), open: "always" }]],
28
- timeout: 60 * 1000,
29
- expect: {
30
- timeout: 5 * 1000,
31
- },
32
-
33
- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
34
- use: {
35
- /* Base URL to use in actions like `await page.goto('/')`. */
36
- //baseURL: process.env.domain,
37
-
38
- /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
39
- trace: 'on',
40
- video: {
41
- mode: 'on',
42
- size: { width: 640, height: 480 }
43
- }
44
- },
45
-
46
- /* Configure projects for major browsers */
47
- projects: [
48
- { name: 'setup', testMatch: /.*\.setup\.js/ },
49
- {
50
- name: 'chromium',
51
- use: {
52
- ...devices['Desktop Chrome'],
53
- storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
54
- },
55
- dependencies: ['setup'],
56
- },
57
-
58
- {
59
- name: 'firefox',
60
- timeout: 4 * 60 * 1000,
61
- expect: {
62
- timeout: 80 * 1000,
63
- },
64
- use: {
65
- ...devices['Desktop Firefox'],
66
- storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
67
- },
68
- dependencies: ['setup'],
69
- },
70
-
71
- {
72
- name: 'webkit',
73
- timeout: 2 * 60 * 1000,
74
- expect: {
75
- timeout: 80 * 1000,
76
- },
77
- use: {
78
- ...devices['Desktop Safari'],
79
- storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
80
- },
81
- dependencies: ['setup'],
82
- },
83
-
84
- /* Test against mobile viewports. */
85
- // {
86
- // name: 'Mobile Chrome',
87
- // use: { ...devices['Pixel 5'] },
88
- // },
89
- // {
90
- // name: 'Mobile Safari',
91
- // use: { ...devices['iPhone 12'] },
92
- // },
93
-
94
- /* Test against branded browsers. */
95
- // {
96
- // name: 'Microsoft Edge',
97
- // use: { ...devices['Desktop Edge'], channel: 'msedge' },
98
- // },
99
- // {
100
- // name: 'Google Chrome',
101
- // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
102
- // },
103
- ],
104
-
105
- /* Run your local dev server before starting the tests */
106
- // webServer: {
107
- // command: 'npm run start',
108
- // url: 'http://127.0.0.1:3000',
109
- // reuseExistingServer: !process.env.CI,
110
- // },
111
- });
112
-
1
+ // @ts-check
2
+ const { defineConfig, devices } = require('@playwright/test');
3
+ const path = require('path');
4
+ const numCPUs = require('os').cpus().length;
5
+
6
+ /**
7
+ * Read environment variables from file.
8
+ * https://github.com/motdotla/dotenv
9
+ */
10
+ // require('dotenv').config();
11
+
12
+ /**
13
+ * @see https://playwright.dev/docs/test-configuration
14
+ */
15
+ module.exports = defineConfig({
16
+ testDir: path.join(path.resolve(process.cwd()), 'uat'),
17
+ outputDir: path.join(process.cwd(), 'test-results'),
18
+ /* Run tests in files in parallel */
19
+ fullyParallel: true,
20
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
21
+ forbidOnly: !!process.env.CI,
22
+ /* Retry on CI only */
23
+ retries: process.env.CI ? 2 : 0,
24
+ /* Opt out of parallel tests on CI. */
25
+ workers: process.env.CI ? 1 : 1,
26
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
27
+ reporter: [['html', { outputFolder: path.join(process.cwd(), 'playwright-report'), open: "always" }]],
28
+ timeout: 60 * 1000,
29
+ expect: {
30
+ timeout: 5 * 1000,
31
+ },
32
+
33
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
34
+ use: {
35
+ /* Base URL to use in actions like `await page.goto('/')`. */
36
+ //baseURL: process.env.domain,
37
+
38
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
39
+ trace: 'on',
40
+ video: {
41
+ mode: 'on',
42
+ size: { width: 640, height: 480 }
43
+ }
44
+ },
45
+
46
+ /* Configure projects for major browsers */
47
+ projects: [
48
+ { name: 'setup', testMatch: /.*\.setup\.js/ },
49
+ {
50
+ name: 'chromium',
51
+ use: {
52
+ ...devices['Desktop Chrome'],
53
+ storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
54
+ },
55
+ dependencies: ['setup'],
56
+ },
57
+
58
+ {
59
+ name: 'firefox',
60
+ timeout: 4 * 60 * 1000,
61
+ expect: {
62
+ timeout: 80 * 1000,
63
+ },
64
+ use: {
65
+ ...devices['Desktop Firefox'],
66
+ storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
67
+ },
68
+ dependencies: ['setup'],
69
+ },
70
+
71
+ {
72
+ name: 'webkit',
73
+ timeout: 2 * 60 * 1000,
74
+ expect: {
75
+ timeout: 80 * 1000,
76
+ },
77
+ use: {
78
+ ...devices['Desktop Safari'],
79
+ storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
80
+ },
81
+ dependencies: ['setup'],
82
+ },
83
+
84
+ /* Test against mobile viewports. */
85
+ // {
86
+ // name: 'Mobile Chrome',
87
+ // use: { ...devices['Pixel 5'] },
88
+ // },
89
+ // {
90
+ // name: 'Mobile Safari',
91
+ // use: { ...devices['iPhone 12'] },
92
+ // },
93
+
94
+ /* Test against branded browsers. */
95
+ // {
96
+ // name: 'Microsoft Edge',
97
+ // use: { ...devices['Desktop Edge'], channel: 'msedge' },
98
+ // },
99
+ // {
100
+ // name: 'Google Chrome',
101
+ // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
102
+ // },
103
+ ],
104
+
105
+ /* Run your local dev server before starting the tests */
106
+ // webServer: {
107
+ // command: 'npm run start',
108
+ // url: 'http://127.0.0.1:3000',
109
+ // reuseExistingServer: !process.env.CI,
110
+ // },
111
+ });
112
+
@@ -1,9 +1,9 @@
1
- const babelJest = require('babel-jest');
2
-
3
- module.exports = babelJest.createTransformer({
4
- presets: [
5
- require.resolve('@babel/preset-env'),
6
- require.resolve('@babel/preset-react')
7
- ],
8
- plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
9
- });
1
+ const babelJest = require('babel-jest');
2
+
3
+ module.exports = babelJest.createTransformer({
4
+ presets: [
5
+ require.resolve('@babel/preset-env'),
6
+ require.resolve('@babel/preset-react')
7
+ ],
8
+ plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
9
+ });
@@ -1,45 +1,45 @@
1
- // import { run } from 'jest';
2
-
3
- // function createJestRunner() {
4
- // let config = require('../configs/jest.config');
5
-
6
- // let argv = process.argv.slice(2);
7
-
8
- // argv.push('--config', JSON.stringify(config(folder)), '--no-cache');
9
- // run(argv);
10
- // }
11
-
12
-
13
- // export default createJestRunner;
14
-
15
- const { spawn } = require('child_process');
16
- const path = require('path');
17
- const getFilePathWithExtension = require('../../../utils/getFilePath');
18
- const { getBinPath } = require('../../../utils/rootPath');
19
-
20
- const jestPath = path.resolve(getBinPath(), getFilePathWithExtension('jest'));
21
-
22
- // Command and arguments for npx playwright test
23
- const command = jestPath;
24
- const args = ['--config', require.resolve('../../../../jest.config.js')];
25
-
26
-
27
- function createJestRunner() {
28
- // Spawn the child process
29
-
30
- const childProcess = spawn(command, args, { stdio: 'inherit' });
31
-
32
-
33
- // Handling the 'exit' event of the child process
34
- // childProcess.on('exit', (code, signal) => {
35
- // console.log(`Child process exited with code ${code} and signal ${signal}`);
36
- // });
37
-
38
- // // Handling any error that occurs while spawning the child process
39
- // childProcess.on('error', (err) => {
40
- // console.error(`Error while spawning child process: ${err.message}`);
41
- // });
42
- }
43
-
44
-
45
- module.exports = createJestRunner;
1
+ // import { run } from 'jest';
2
+
3
+ // function createJestRunner() {
4
+ // let config = require('../configs/jest.config');
5
+
6
+ // let argv = process.argv.slice(2);
7
+
8
+ // argv.push('--config', JSON.stringify(config(folder)), '--no-cache');
9
+ // run(argv);
10
+ // }
11
+
12
+
13
+ // export default createJestRunner;
14
+
15
+ const { spawn } = require('child_process');
16
+ const path = require('path');
17
+ const getFilePathWithExtension = require('../../../utils/getFilePath');
18
+ const { getBinPath } = require('../../../utils/rootPath');
19
+
20
+ const jestPath = path.resolve(getBinPath(), getFilePathWithExtension('jest'));
21
+
22
+ // Command and arguments for npx playwright test
23
+ const command = jestPath;
24
+ const args = ['--config', require.resolve('../../../../jest.config.js')];
25
+
26
+
27
+ function createJestRunner() {
28
+ // Spawn the child process
29
+
30
+ const childProcess = spawn(command, args, { stdio: 'inherit' });
31
+
32
+
33
+ // Handling the 'exit' event of the child process
34
+ // childProcess.on('exit', (code, signal) => {
35
+ // console.log(`Child process exited with code ${code} and signal ${signal}`);
36
+ // });
37
+
38
+ // // Handling any error that occurs while spawning the child process
39
+ // childProcess.on('error', (err) => {
40
+ // console.error(`Error while spawning child process: ${err.message}`);
41
+ // });
42
+ }
43
+
44
+
45
+ module.exports = createJestRunner;