webdriverio / visual-testing

Image comparison / visual regression testing for WebdriverIO
https://webdriver.io/docs/visual-testing
MIT License
109 stars 38 forks source link

Config file is not finding the visual-service and throws an error on browser.saveScreen("name") function #232

Open dublinstand opened 6 months ago

dublinstand commented 6 months ago

Environment (please complete the following information):

Config of WebdriverIO + @wdio/visual-service An example of how you configured the @wdio/visual-service

const { join } = require('path');

exports.config = { // ... // ===== // Setup // ===== services: [ ['visual', { // Some options, see the docs for more baselineFolder: join(process.cwd(), 'tests', 'baseline'), formatImageName: '{tag}-{logName}-{width}x{height}', screenshotPath: join(process.cwd(), 'tmp'), savePerInstance: true, autoSaveBaseline: true, blockOutStatusBar: true, blockOutToolBar: true, // NOTE: When you are testing a hybrid app please use this setting isHybridApp: false, // Options for the tabbing image tabbableOptions: { circle: { size: 18, fontSize: 18, // ... }, line: { color: "#ff221a", // hex-code or for example words like red|black|green width: 3, }, }, // ... more options }] ],

Describe the bug An error is thrown when running the tests

To Reproduce Steps to reproduce the behavior: [Include code or an example repository that can easily be set up]

Expected behavior A clear and concise description of what you expected to happen.

Log

2024-02-19T16:39:10.502Z ERROR @wdio/config:ConfigParser: Failed loading configuration file: C:\Users\dubli\OneDrive\Des ktop\1\JavaScript\packages\webdriverio\wdio.conf.winappdriver.js: require() of ES Module C:\Users\dubli\OneDrive\Desktop \1\JavaScript\packages\webdriverio\wdio.conf.winappdriver.js from C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modu les\@wdio\config\build\lib\ConfigParser.js not supported. wdio.conf.winappdriver.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename wdio.conf.winappdriver.js to end in .cjs, change the requiring code to use dynamic import() which is avai lable in all CommonJS modules, or change "type": "module" to "type": "commonjs" in C:\Users\dubli\OneDrive\Desktop\1\Jav aScript\packages\webdriverio\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\config\build\lib\ConfigParser.js:43 var fileConfig = (0, _deepmerge.default)(require(filePath).config, {}, MERGE_OPTIONS); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\dubli\OneDrive\Desktop\1\JavaScript\packages\webdriverio\wdio.c onf.winappdriver.js from C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\config\build\lib\ConfigParser.j s not supported. wdio.conf.winappdriver.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename wdio.conf.winappdriver.js to end in .cjs, change the requiring code to use dynamic import() which is avai lable in all CommonJS modules, or change "type": "module" to "type": "commonjs" in C:\Users\dubli\OneDrive\Desktop\1\Jav aScript\packages\webdriverio\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at ConfigParser.addConfigFile (C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\config\build\lib\Conf

igParser.js:43:48) at new Launcher (C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\cli\build\launcher.js:33:23) at launch (C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\cli\build\run.js:63:20) at run (C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\cli\build\run.js:45:12) at Object.run (C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\cli\build\index.js:36:20) at Object. (C:\Users\dubli\OneDrive\Desktop\1\JavaScript\node_modules\@wdio\cli\bin\wdio.js:11:21) { code: 'ERR_REQUIRE_ESM' }

Node.js v18.16.0 npm ERR! Lifecycle script test failed with error:

Additional context Add any other context about the problem here.

christian-bromann commented 6 months ago

@dublinstand can you please provide some description of what you are trying to do, your environment and what you expect to happen? Just posting an error message is not very helpful :-/ please provide a reproducible example if possible!

wswebcreation commented 6 months ago

Hi @christian-bromann

it’s my fault, I’m helping @dublinstand , see also https://discord.com/channels/1097401827202445382/1209128559340159026

repo link is also in the description

wswebcreation commented 6 months ago

I'm not able to properly set up the appium-windows-driver on an old windows machine. I'll keep this open for people who have more patience and time for Windows to help with this. For now appium-windows-driver is not supported with this module