Skip to content

Commit 1326e99

Browse files
feat: add new package @wdio/image-comparison-core (#982) (#994)
* feat: add new package @wdio/image-comparison-core Started - migrating code - optimize types - remove executor and replace by wdio methods * feat: update getMobileViewPortPosition - fix tests * chore: replaced takeBase64Screenshot implementation - updated tests * chore: fixed afterScreenshot - updated tests * chore: updated beforeScreenshot - fixed and added UT's * chore: clean saveWebScreen from methods - fix UT's * chore: update checkScreen * chore: fix checkWebScreen * chore: fix saveElement and checkElement * chore: add full/tabbable page * chore: remove methods * chore: adjust the visual service to use the new core * chore: migrated the service to the new module - fixed UTs and imports * chore: add browserInstance to the commands * chore: added the browserinstance back and fix UTs * fix UT's * fix tests * chore: cleanup methods * chore: remove webdriver-image-comparison * chore: multiple fixes - fix BiDi check - fix determining iOS currentOffsets - fix calculating remaining content for mobile fullpage screenshots - add extra debug logging when the fullpage scroll becomes negative - updated baselines * chore: fix UT's * chore: optimize types * test: add tests vor checkAppElement * chore: make private package public * test: add checkAppScreen tests * tesT: add new tests * chore: refactor mocks * chore: simplify checks * test: add checkScreen tests * test: add checkTabbablePage * test: add checkWebElement fix some styling * chore: revert Sauce tests * test: add checkWebScreen * test: add checkWebScreen tests - some linting shit * chore: update eslint * test: add saveAppElement * chore: fix folders * chore: fix some tests * test: add saveAppScreen * test: add saveElement * tesT: add saveFullPageScreen test * test: add saveScreen tests * test: add saveTabbablePage tests * test: add saveWebElement tests * test: add saveWebScreen tests * chore: create BEFORE_SCREENSHOT_MOCK * chore: optimize mocks - saveWebElement - saveAppScreen - saveAppElement - saveWebScreen - saveTabbablePage - saveElement - mocks file * test: add drawTabbableOnCanvas tests * test: add more tests drawTabbableOnCanvas * test: add more tests for drawTabbableOnCanvas * test: update drawTabbableOnCanvas - add comments for whats's not properly testable * chore: added todo's * test: add scrollElementIntoView tests - fix screendimentions test * test: add scrollToPosition tests * test: add createCompareReport tests * test: add processDiffPixels * test: add makeCroppedBase64Image tests * test: add executeImageCompare tests * test: add makeFullPageBase64Image tests * test: add takeResizedBase64Screenshot tests * fix: fix object comparison and add proper logging for takeBase64ElementScreenshot - add new UT's for takeBase64ElementScreenshot part 1 * test: add more tests for takeBase64ElementScreenshot * fix: fix images tests * chore: use snapshots * test: add takeWebElementScreenshot tests * test: add logHiddenRemovedError * test: add getDesktopFullPageScreenshotsData * test: add getAndroidChromeDriverFullPageScreenshotsData * test: add getMobileFullPageNativeWebScreenshotsData * chore: some small fixes * Refactor code (#987) * feat: refactor getBase64FullPageScreenshotsData router - update ut's * chore: update tests * chore: refactor beforeOptions - update saveFullPageScreen and tests * feat: adjust saveWebScreen with createBeforeScreenshotOptions * feat: adjust saveWebElement for createBeforeScreenshotOptions * chore: optimise saveWebElement * chore: restructure interface * chore: refactor afterScreenshot options - implemented for saveWebScreen * chore: refactor for saveWebElement * chore: refactor saveFullPageScreen * chore: refactor saveAppScreen * chore: refactor saveAppElement * chore: refactor saveWebScreen * chore: refactor screenshot interfaces * chore: and the rest * chore: use snapshots for tests * fix: fallback for elementscreeshots was broken due to incorrect calculation, also fixed UT's * chore: fix local desktop run * chore: fix some comments * chore: code optimisation - afterscreenshot for readability * chore: optimisations - make takeElementScreenshot more readable - fix UT for afterscreenshot - add check on calling logger for afterscreenshot * chore: then also commit the afterscreenshot stuff * chore: refactor a CommonCheckVariables - adjust files - create UT's * chore: refactor to use buildFolderOptions - adjust methods - add and adjust UTs * chore: refactor methods options - added buildBaseExecuteCompareOptions - added and adjusted UT's * chore: refactor checkAppElement and checkAppScreen * chore: refactored images and report code - updated interfaces - made code more dry and maintainable - updated UTs * chore: fix linting * chore: fix build * Chore: remove comments * chore: update deps * chore: add release notes
1 parent 9e0f788 commit 1326e99

File tree

293 files changed

+36696
-10449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+36696
-10449
lines changed

.changeset/shy-coins-drive.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
"@wdio/image-comparison-core": major
3+
"@wdio/visual-service": major
4+
"@wdio/visual-reporter": patch
5+
"@wdio/ocr-service": patch
6+
---
7+
8+
## 💥 Major Release: New @wdio/image-comparison-core Package
9+
10+
### 🏗️ Architectural Refactor
11+
12+
This release introduces a **completely new core architecture** with the dedicated `@wdio/image-comparison-core` package, replacing the generic `webdriver-image-comparison` module with a WDIO-specific solution.
13+
14+
#### What was the problem?
15+
- The old `webdriver-image-comparison` package was designed for generic webdriver usage
16+
- Complex integration between generic and WDIO-specific code
17+
- Limited test coverage (~58%) making maintenance difficult
18+
- Mixed responsibilities between core logic and service integration
19+
20+
#### What changed?
21+
**New dedicated core package**: `@wdio/image-comparison-core` - purpose-built for WebdriverIO
22+
**Cleaner architecture**: Modular design with clear separation of concerns
23+
**Enhanced test coverage**: Improved from ~58% to ~90% across all metrics
24+
**Better maintainability**: Organized codebase with comprehensive TypeScript interfaces
25+
**WDIO-specific dependencies**: Only depends on `@wdio/logger`, `@wdio/types`, etc.
26+
27+
### 🧪 Testing Improvements
28+
29+
- **100% branch coverage** on critical decision points
30+
- **Comprehensive unit tests** for all major functions
31+
- **Optimized mocks** for complex scenarios
32+
- **Better test isolation** and reliability
33+
34+
| Before/After | % Stmts | % Branch | % Funcs | % Lines |
35+
| ------------ | ------- | -------- | ------- | ------- |
36+
| **Previous** | 58.59 | 91.4 | 80.71 | 58.59 |
37+
| **After refactor** | 90.55 | 96.38 | 93.99 | 90.55 |
38+
39+
### 🔧 Service Integration
40+
41+
The `@wdio/visual-service` now imports from the new `@wdio/image-comparison-core` package while maintaining the same public API and functionality for users.
42+
43+
### 📈 Performance & Quality
44+
45+
- **Modular architecture**: Easier to maintain and extend
46+
- **Type safety**: Comprehensive TypeScript coverage
47+
- **Clean exports**: Well-defined public API
48+
- **Internal interfaces**: Proper separation of concerns
49+
50+
### 🔄 Backward Compatibility
51+
52+
**No breaking changes** for end users
53+
**Same public API** maintained
54+
**Existing configurations** continue to work
55+
**All existing functionality** preserved
56+
57+
### 🎯 Future Benefits
58+
59+
This refactor sets the foundation for:
60+
- Easier addition of new features
61+
- Better bug fixing capabilities
62+
- Enhanced mobile and native app support
63+
- More reliable MultiRemote functionality
64+
65+
### 📦 Dependency Updates
66+
- Updated most dependencies to their latest versions
67+
- Improved security with latest package versions
68+
- Better compatibility with current WebdriverIO ecosystem
69+
- Enhanced performance through updated dependencies
70+
71+
---
72+
73+
**Note**: This is an architectural improvement that modernizes the codebase while maintaining full backward compatibility. All existing functionality remains unchanged for users.
74+
75+
---
76+

eslint.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = [
77
'**/dist/*',
88
'**/build/*',
99
'**/.next/*',
10+
'**/.vitest-ui/*',
1011
]
1112
},
1213
{

package.json

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,50 +51,45 @@
5151
"prepare": "husky",
5252
"watch": "pnpm run -r --parallel watch"
5353
},
54-
"dependencies": {
55-
"@wdio/ocr-service": "workspace:*",
56-
"@wdio/visual-service": "workspace:*",
57-
"webdriver-image-comparison": "workspace:*"
58-
},
5954
"devDependencies": {
60-
"@changesets/cli": "^2.29.4",
61-
"@tsconfig/node20": "^20.1.5",
55+
"@changesets/cli": "^2.29.5",
56+
"@tsconfig/node20": "^20.1.6",
6257
"@types/eslint": "^9.6.1",
6358
"@types/inquirer": "^9.0.8",
6459
"@types/jsdom": "~21.1.7",
65-
"@types/node": "^22",
60+
"@types/node": "^24",
6661
"@types/xml2js": "~0.4.14",
67-
"@typescript-eslint/eslint-plugin": "^8.32.0",
68-
"@wdio/globals": "^9.13.0",
69-
"@wdio/mocha-framework": "^9.14.0",
70-
"@typescript-eslint/parser": "^8.32.0",
71-
"@typescript-eslint/utils": "^8.31.1",
72-
"@vitest/coverage-v8": "^3.1.1",
73-
"@vitest/ui": "^3.1.1",
74-
"@wdio/appium-service": "^9.13.0",
75-
"@wdio/browserstack-service": "^9.14.0",
76-
"@wdio/cli": "^9.14.0",
77-
"@wdio/local-runner": "^9.14.0",
78-
"@wdio/sauce-service": "^9.14.0",
79-
"@wdio/shared-store-service": "^9.14.0",
80-
"@wdio/spec-reporter": "^9.14.0",
81-
"@wdio/types": "^9.14.0",
62+
"@typescript-eslint/eslint-plugin": "^8.37.0",
63+
"@wdio/globals": "^9.17.0",
64+
"@wdio/mocha-framework": "^9.18.0",
65+
"@typescript-eslint/parser": "^8.37.0",
66+
"@typescript-eslint/utils": "^8.37.0",
67+
"@vitest/coverage-v8": "^3.2.4",
68+
"@vitest/ui": "^3.2.4",
69+
"@wdio/appium-service": "^9.18.1",
70+
"@wdio/browserstack-service": "^9.18.1",
71+
"@wdio/cli": "^9.18.1",
72+
"@wdio/local-runner": "^9.18.1",
73+
"@wdio/sauce-service": "^9.18.1",
74+
"@wdio/shared-store-service": "^9.18.1",
75+
"@wdio/spec-reporter": "^9.18.0",
76+
"@wdio/types": "^9.16.2",
8277
"cross-env": "^7.0.3",
83-
"eslint": "^9.27.0",
84-
"eslint-plugin-import": "^2.31.0",
78+
"eslint": "^9.31.0",
79+
"eslint-plugin-import": "^2.32.0",
8580
"eslint-plugin-unicorn": "^56.0.1",
86-
"eslint-plugin-wdio": "^9.9.1",
81+
"eslint-plugin-wdio": "^9.16.2",
8782
"husky": "^9.1.7",
8883
"jsdom": "^26.1.0",
89-
"npm-run-all2": "^7.0.2",
90-
"release-it": "^18.1.2",
84+
"npm-run-all2": "^8.0.4",
85+
"release-it": "^19.0.4",
9186
"rimraf": "^6.0.1",
9287
"saucelabs": "^9.0.2",
9388
"ts-node": "^10.9.2",
9489
"typescript": "^5.8.3",
95-
"vitest": "^3.1.1",
96-
"webdriverio": "^9.14.0",
90+
"vitest": "^3.2.4",
91+
"webdriverio": "^9.18.1",
9792
"wdio-lambdatest-service": "^4.0.0"
9893
},
9994
"packageManager": "[email protected]+sha256.cf86a7ad764406395d4286a6d09d730711720acc6d93e9dce9ac7ac4dc4a28a7"
100-
}
95+
}
File renamed without changes.
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
WebdriverIO Image Comparison Core
2+
==========================
3+
4+
## Installation
5+
6+
The easiest way is to keep `@wdio/image-comparison-core` as a dev-dependency in your `package.json`, via:
7+
8+
```sh
9+
npm install @wdio/image-comparison-core --save-dev
10+
```
11+
12+
Instructions on how to get started can be found in the [visual testing](https://webdriver.io/docs/visual-testing) docs on the WebdriverIO project page.

packages/webdriver-image-comparison/assets/ios/ipadair4th.ipadair5th-bottom.png renamed to packages/image-comparison-core/assets/ios/ipadair4th.ipadair5th-bottom.png

File renamed without changes.

packages/webdriver-image-comparison/assets/ios/ipadair4th.ipadair5th-top.png renamed to packages/image-comparison-core/assets/ios/ipadair4th.ipadair5th-top.png

File renamed without changes.

packages/webdriver-image-comparison/assets/ios/ipadmini6th-bottom.png renamed to packages/image-comparison-core/assets/ios/ipadmini6th-bottom.png

File renamed without changes.

packages/webdriver-image-comparison/assets/ios/ipadmini6th-top.png renamed to packages/image-comparison-core/assets/ios/ipadmini6th-top.png

File renamed without changes.

0 commit comments

Comments
 (0)