visual-testing: Snapshot service is not initialized
Environment (please complete the following information):
- Node.js version: 22.11.0
- NPM version: 10.9.1
- Platform name and version: Android 11 (testing on native android app)
- WebdriverIO version: 9.4.1
@wdio/visual-serviceversion: 6.2.2@wdio/mocha-frameworkversion: 9.2.8@wdio/local-runnerversion: 9.4.1@wdio/globalsversion: 9.4.1@wdio/cliversion: 9.4.1Appiumversion: 2.11.5tsxversion: 4.19.2
Config of WebdriverIO + @wdio/visual-service
services: [
// your other services
[
"ocr",
{
contrast: 0.25,
imagesFolder: "./onboard/output"
},
],
[
"visual",
{
baselineFolder: path.join(process.cwd(), "onboard", "baseline"),
formatImageName: "{tag}-{width}x{height}-{dpr}",
screenshotPath: path.join(process.cwd(), "onboard", "output", "visual"),
savePerInstance: true,
clearRuntimeFolder: true,
},
],
],
Describe the bug After my typescript migration, it no longer work.
- With “toMatchElementSnapshot” (The issue is not explicit.)
[0-0] takeBase64ElementScreenshot element is not a valid element because of "Login-logoApp"
[0-0] 2024-12-03T16:12:23.611Z INFO @wdio/visual-service:webdriver-image-comparison:images: awaitedElement = "Login-logoApp"
[0-0] Error taking an element screenshot with the default `element.takeElementScreenshot(elementId)` method: TypeError: awaitedElement.takeElementScreenshot is not a function
[0-0] at takeBase64ElementScreenshot (file:///C:/Users/My%20Name/automatisation/MatatestJS/node_modules/webdriver-image-comparison/dist/methods/images.js:452:41)
[0-0] at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
[0-0] at async saveAppElement (file:///C:/Users/My%20Name/automatisation/MatatestJS/node_modules/webdriver-image-comparison/dist/commands/saveAppElement.js:14:25)
[0-0] at async checkAppElement (file:///C:/Users/My%20Name/automatisation/MatatestJS/node_modules/webdriver-image-comparison/dist/commands/checkAppElement.js:12:57) We will retry with a resized screenshot
- With “toMatchSnapshot”:
"status": "broken",
"statusDetails": {
"message": "Snapshot service is not initialized",
"trace": "Error: Snapshot service is not initialized\n at __EXTERNAL_MATCHER_TRAP__ (C:\\Users\\My NAME\\automatisation\\MatatestJS\\node_modules\\expect\\build\\index.js:325:30)\n at Object.throwingMatcher [as toMatchSnapshot] (C:\\Users\\My NAME\\automatisation\\MatatestJS\\node_modules\\expect\\build\\index.js:326:15)\n at loginPage.checkLoginPage (C:\\Users\\My NAME\\automatisation\\MatatestJS\\onboard\\pageObjects\\mobile\\loginPage.ts:133:23)\n at async Context.<anonymous> (C:\\Users\\My NAME\\automatisation\\MatatestJS\\onboard\\specs\\login.ts:71:13)\n at async Context.executeAsync (C:\\Users\\My NAME\\automatisation\\MatatestJS\\node_modules\\@wdio\\utils\\build\\index.js:1004:20)\n at async Context.testFrameworkFnWrapper (C:\\Users\\My NAME\\automatisation\\MatatestJS\\node_modules\\@wdio\\utils\\build\\index.js:1075:14)"
},
💡It work as expected with saveScreen and checkScreen Only snapshot service seems to be in issue.
Expected behavior Snapshot service is initialized correctly, “toMatchSnapshot” and “toMatchElementSnapshot” work as expected
Additional context I’m using typescript and my tsconfig contain:
"types": [
"node",
"@wdio/globals/types",
"@wdio/mocha-framework",
"@wdio/appium-service",
"@wdio/ocr-service",
"@wdio/visual-service",
"i18next"
]
Links:
-
My discord question about this subject:
-
Someone with similar issue in discord:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (10 by maintainers)
@P-Courteille
I’ve released a new version if you use 6.2.3 most of the issues should be gone
Hi @P-Courteille
I’ll check this. This log
means that it can’t find a local installed version of Tesseract. It will now use the NodeJS dependency. If you have the option to use a native installed version of Tessaract you will see it will be much faster. See also https://webdriver.io/docs/ocr-testing/more-test-optimization
I’ll try to run my tests again with only the NodeJS vesion
Hi @wswebcreation, I will try to create this example. The one I did from scratch doesn’t reproduce the behavior so I will compare again with my previous MR and if I don’t find anything I will try to create an example by removing all the useless things from my project.
Thank you for your help