@wdio/ocr-service 1.0.3 → 1.0.5

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +172 -4
  2. package/dist/cli.js +31 -53
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,17 +1,185 @@
1
1
  # @wdio/ocr-service
2
2
 
3
- ## 1.0.3
3
+ ## 1.0.5
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- # 💅 Polish
8
-
9
- Update deps
7
+ - 85a1d82: # 🐛 Bug Fixes
8
+
9
+ Fix issues:
10
+
11
+ - [438](https://github.com/webdriverio/visual-testing/issues/438): resizeDimensions not working
12
+ - [448](https://github.com/webdriverio/visual-testing/issues/448): hideElements and removeElements` don't work for native apps
13
+
14
+ # 💅 Polish
15
+
16
+ - update dependencies
10
17
 
11
18
  # Committers: 1
12
19
 
13
20
  - Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
14
21
 
22
+ ## 1.0.4
23
+
24
+ ### Patch Changes
25
+
26
+ - 0b01b64: ### @wdio/visual-service
27
+
28
+ #### 🚀 New Features
29
+
30
+ **Added Reporting output**
31
+ You now have the option to export the compare results into a JSON report file. By enabling the module option `createJsonReportFiles: true`, each image that is compared will create a report stored in the `actual` folder, next to each `actual` image result.
32
+
33
+ The output will look like this:
34
+
35
+ ```json
36
+ {
37
+ "parent": "check methods",
38
+ "test": "should fail comparing with a baseline",
39
+ "tag": "examplePageFail",
40
+ "instanceData": {
41
+ "browser": {
42
+ "name": "chrome-headless-shell",
43
+ "version": "126.0.6478.183"
44
+ },
45
+ "platform": {
46
+ "name": "mac",
47
+ "version": "not-known"
48
+ }
49
+ },
50
+ "commandName": "checkScreen",
51
+ "boundingBoxes": {
52
+ "diffBoundingBoxes": [
53
+ {
54
+ "left": 1088,
55
+ "top": 717,
56
+ "right": 1186,
57
+ "bottom": 730
58
+ }
59
+ //....
60
+ ],
61
+ "ignoredBoxes": [
62
+ {
63
+ "left": 159,
64
+ "top": 652,
65
+ "right": 356,
66
+ "bottom": 703
67
+ }
68
+ //...
69
+ ]
70
+ },
71
+ "fileData": {
72
+ "actualFilePath": "/Users/wswebcreation/Git/wdio/visual-testing/.tmp/actual/desktop_chrome-headless-shellexamplePageFail-local-chrome-latest-1366x768.png",
73
+ "baselineFilePath": "/Users/wswebcreation/Git/wdio/visual-testing/localBaseline/desktop_chrome-headless-shellexamplePageFail-local-chrome-latest-1366x768.png",
74
+ "diffFilePath": "/Users/wswebcreation/Git/wdio/visual-testing/.tmp/diff/desktop_chrome-headless-shell/examplePageFail-local-chrome-latest-1366x768png",
75
+ "fileName": "examplePageFail-local-chrome-latest-1366x768.png",
76
+ "size": {
77
+ "actual": {
78
+ "height": 768,
79
+ "width": 1366
80
+ },
81
+ "baseline": {
82
+ "height": 768,
83
+ "width": 1366
84
+ },
85
+ "diff": {
86
+ "height": 768,
87
+ "width": 1366
88
+ }
89
+ }
90
+ },
91
+ "misMatchPercentage": "12.90",
92
+ "rawMisMatchPercentage": 12.900729014153246
93
+ }
94
+ ```
95
+
96
+ When all tests are executed, a new JSON file with the collection of the comparisons will be generated and can be found in the root of your actual folder. The data is grouped by:
97
+
98
+ - `describe` for Jasmine/Mocha or `Feature` for CucumberJS
99
+ - `it` for Jasmine/Mocha or `Scenario` for CucumberJS
100
+
101
+ and then sorted by:
102
+
103
+ - `commandName`, which are the compare method names used to compare the images
104
+ - `instanceData`, browser first, then device, then platform
105
+
106
+ it will look like this
107
+
108
+ ```json
109
+ [
110
+ {
111
+ "description": "check methods",
112
+ "data": [
113
+ {
114
+ "test": "should fail comparing with a baseline",
115
+ "data": [
116
+ {
117
+ "tag": "examplePageFail",
118
+ "instanceData": {},
119
+ "commandName": "checkScreen",
120
+ "framework": "mocha",
121
+ "boundingBoxes": {
122
+ "diffBoundingBoxes": [],
123
+ "ignoredBoxes": []
124
+ },
125
+ "fileData": {},
126
+ "misMatchPercentage": "14.34",
127
+ "rawMisMatchPercentage": 14.335403703025868
128
+ },
129
+ {
130
+ "tag": "exampleElementFail",
131
+ "instanceData": {},
132
+ "commandName": "checkElement",
133
+ "framework": "mocha",
134
+ "boundingBoxes": {
135
+ "diffBoundingBoxes": [],
136
+ "ignoredBoxes": []
137
+ },
138
+ "fileData": {},
139
+ "misMatchPercentage": "1.34",
140
+ "rawMisMatchPercentage": 1.335403703025868
141
+ }
142
+ ]
143
+ }
144
+ ]
145
+ }
146
+ ]
147
+ ```
148
+
149
+ The report data will give you the opportunity to build your own visual report without doing all the magic and data collection yourself.
150
+
151
+ ### webdriver-image-comparison
152
+
153
+ #### 🚀 New Features
154
+
155
+ - Add support to generate single JSON report files
156
+
157
+ ### @wdio/ocr-service
158
+
159
+ #### 💅 Polish
160
+
161
+ - Refactored the CLI to use `@inquirer/prompts` instead of `inquirer`
162
+
163
+ ### Committers: 1
164
+
165
+ - Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
166
+
167
+ ```
168
+
169
+ ```
170
+
171
+ ## 1.0.3
172
+
173
+ ### Patch Changes
174
+
175
+ # 💅 Polish
176
+
177
+ Update deps
178
+
179
+ # Committers: 1
180
+
181
+ - Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
182
+
15
183
  ## 1.0.2
16
184
 
17
185
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import inquirer from 'inquirer';
2
+ import { input, confirm, select } from '@inquirer/prompts';
3
3
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
4
4
  import { join, resolve } from 'node:path';
5
5
  import getData from './utils/getData.js';
@@ -46,19 +46,17 @@ function listFilesAndFolders(folderPath) {
46
46
  async function chooseFolder(currentPath) {
47
47
  async function prompt(srcPath) {
48
48
  const choices = listFilesAndFolders(srcPath);
49
- const answers = await inquirer.prompt([{
50
- type: 'list',
51
- name: 'path',
52
- message: `Please choose a folder (current folder: ${srcPath})`,
53
- choices: choices
54
- }]);
55
- const newPath = join(srcPath, answers.path);
56
- if (answers.path === '..') {
49
+ const answers = await select({
50
+ message: `Please choose a folder (current folder: ${srcPath})`,
51
+ choices: choices
52
+ });
53
+ const newPath = join(srcPath, answers);
54
+ if (answers === '..') {
57
55
  // Clears the previous line
58
56
  process.stdout.write('\u001b[1A\u001b[2K');
59
57
  return prompt(newPath);
60
58
  }
61
- if (answers.path.endsWith('/')) {
59
+ if (answers.endsWith('/')) {
62
60
  // Clears the previous line
63
61
  process.stdout.write('\u001b[1A\u001b[2K');
64
62
  return prompt(newPath);
@@ -77,54 +75,40 @@ async function main() {
77
75
  };
78
76
  let filePath;
79
77
  console.log(CONFIG_HELPER_INTRO);
80
- const initialChoice = await inquirer.prompt({
81
- type: 'list',
82
- name: 'method',
78
+ const initialChoice = await select({
83
79
  message: 'How would you like to specify the file?',
84
80
  choices: [
85
- { name: 'Use a "file explorer"', value: 'explore' },
86
- { name: 'Type the file path manually', value: 'type' },
81
+ { name: 'Use a "file explorer"', value: { method: 'explore' } },
82
+ { name: 'Type the file path manually', value: { method: 'type' } },
87
83
  ],
88
84
  });
89
85
  if (initialChoice.method === 'explore') {
90
86
  filePath = await chooseFolder(currentPath);
91
87
  }
92
88
  else {
93
- const pathInput = await inquirer.prompt({
94
- type: 'input',
95
- name: 'path',
89
+ const pathInput = await input({
96
90
  message: 'Please enter the file path:',
97
91
  });
98
- filePath = pathInput.path;
92
+ filePath = pathInput;
99
93
  }
100
- const useHaystack = await inquirer.prompt({
101
- type: 'confirm',
102
- name: 'use',
94
+ const useHaystack = await confirm({
103
95
  message: 'Would you like to use a haystack?',
104
96
  });
105
97
  let haystack;
106
- if (useHaystack.use) {
107
- const { x } = await inquirer.prompt({
108
- type: 'input',
109
- name: 'x',
98
+ if (useHaystack) {
99
+ const x = await input({
110
100
  message: 'Enter the x coordinate:',
111
101
  validate: (input) => isNaN(Number(input)) ? 'Please enter a valid number' : true,
112
102
  });
113
- const { y } = await inquirer.prompt({
114
- type: 'input',
115
- name: 'y',
103
+ const y = await input({
116
104
  message: 'Enter the y coordinate:',
117
105
  validate: (input) => isNaN(Number(input)) ? 'Please enter a valid number' : true,
118
106
  });
119
- const { width } = await inquirer.prompt({
120
- type: 'input',
121
- name: 'width',
107
+ const width = await input({
122
108
  message: 'Enter the width:',
123
109
  validate: (input) => isNaN(Number(input)) ? 'Please enter a valid number' : true,
124
110
  });
125
- const { height } = await inquirer.prompt({
126
- type: 'input',
127
- name: 'height',
111
+ const height = await input({
128
112
  message: 'Enter the height:',
129
113
  validate: (input) => isNaN(Number(input)) ? 'Please enter a valid number' : true,
130
114
  });
@@ -132,30 +116,24 @@ async function main() {
132
116
  }
133
117
  let options = {
134
118
  ...defaultOptions,
135
- ...{ haystack },
119
+ haystack,
136
120
  cliFile: convertFileToBase64(filePath),
137
121
  };
138
- const { useAdvanced } = await inquirer.prompt([{
139
- type: 'confirm',
140
- name: 'useAdvanced',
141
- message: 'Do you want to use the advanced mode?',
142
- }]);
122
+ const useAdvanced = await confirm({
123
+ message: 'Do you want to use the advanced mode?',
124
+ });
143
125
  if (useAdvanced) {
144
- const advancedOptions = await inquirer.prompt([
145
- {
146
- type: 'input',
147
- name: 'contrast',
148
- message: 'Enter new contrast (0.0 - 1.0):',
149
- default: defaultOptions.contrast.toString(),
150
- validate: (input) => {
151
- const value = parseFloat(input);
152
- return (value >= 0.0 && value <= 1.0) || 'Please enter a contrast between 0.0 and 1.0';
153
- },
126
+ const advancedOptions = await input({
127
+ message: 'Enter new contrast (0.0 - 1.0):',
128
+ default: defaultOptions.contrast.toString(),
129
+ validate: (input) => {
130
+ const value = parseFloat(input);
131
+ return (value >= 0.0 && value <= 1.0) || 'Please enter a contrast between 0.0 and 1.0';
154
132
  },
155
- ]);
133
+ });
156
134
  options = {
157
135
  ...options,
158
- contrast: parseFloat(advancedOptions.contrast),
136
+ contrast: parseFloat(advancedOptions),
159
137
  };
160
138
  }
161
139
  console.log('\nProcessing image...\n');
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wdio/ocr-service",
3
3
  "author": "Wim Selles - wswebcreation",
4
4
  "description": "A WebdriverIO service that is using Tesseract OCR for Desktop/Mobile Web and Mobile Native App tests.",
5
- "version": "1.0.3",
5
+ "version": "1.0.5",
6
6
  "license": "MIT",
7
7
  "homepage": "https://webdriver.io/docs/visual-testing",
8
8
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "@wdio/logger": "^8.38.0",
27
27
  "@wdio/types": "^8.39.0",
28
28
  "fuse.js": "^7.0.0",
29
- "inquirer": "^10.0.1",
29
+ "@inquirer/prompts": "5.3.6",
30
30
  "jimp": "^0.22.12",
31
31
  "node-tesseract-ocr": "^2.2.1",
32
32
  "tesseract.js": "^5.1.0",