You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an error is encountered it is reported in the terminal as expected. However the error reporting directs to the incorrect line. When using ctrl+click on the error location VS Code goes to the same incorrect line.
In the example provided below, the error is on line 9, while the report shows it as line 7. In files with more lines of code this difference is larger.
The autogenerated wdio test with an error introduced:
The terminal output:
[chrome 122.0.6261.128 windows #0-0] » \test\specs\test.e2e.ts
[chrome 122.0.6261.128 windows #0-0] My Login application
[chrome 122.0.6261.128 windows #0-0] ✖ should login with valid credentials
[chrome 122.0.6261.128 windows #0-0]
[chrome 122.0.6261.128 windows #0-0] 1 failing (4.6s)
[chrome 122.0.6261.128 windows #0-0]
[chrome 122.0.6261.128 windows #0-0] 1) My Login application should login with valid credentials
[chrome 122.0.6261.128 windows #0-0] expect(received).toBe(expected) // Object.is equality
Expected: "fail"
Received: "pass"
[chrome 122.0.6261.128 windows #0-0] Error: expect(received).toBe(expected) // Object.is equality
[chrome 122.0.6261.128 windows #0-0]
[chrome 122.0.6261.128 windows #0-0] Expected: "fail"
[chrome 122.0.6261.128 windows #0-0] Received: "pass"
[chrome 122.0.6261.128 windows #0-0] at Context.<anonymous> (file:///C:/Users/cs1lrj/Documents/automation/test/test/specs/test.e2e.ts:7:30)
What is your expected behavior?
The line shown in the error should be the line in which the error occurred.
When using ctrl+click on the error it should take the user to the correct line of code.
How to reproduce the bug.
Run npm init wdio and select the following options:
? A project named "test" was detected at "C:\Users\[my username]\Documents\automation\test", correct? Yes
? What type of testing would you like to do? E2E Testing - of Web or Mobile Applications
? Where is your automation backend located? On my local machine
? Which environment you would like to automate? Web - web applications in the browser
? With which browser should we start? Chrome
? Which framework do you want to use? Mocha (https://mochajs.org/)
? Do you want to use a compiler? TypeScript (https://www.typescriptlang.org/)
? Do you want WebdriverIO to autogenerate some test files? Yes
? What should be the location of your spec files? C:\Users\[my username]\Documents\automation\test\test\specs\**\*.ts
? Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? Yes
? Where are your page objects located? C:\Users\[my username]\Documents\automation\test\test\pageobjects\**\*.ts
? Which reporter do you want to use? spec
? Do you want to add a plugin to your test setup?
? Would you like to include Visual Testing to your setup? For more information see https://webdriver.io/docs/visual-testing! No
? Do you want to add a service to your test setup?
? Do you want me to run `npm install` Yes
Introduce a deliberate failure to the autogenerated test file, for example:
import { expect } from '@wdio/globals'
import LoginPage from '../pageobjects/login.page.js'
import SecurePage from '../pageobjects/secure.page.js'
describe('My Login application', () => {
it('should login with valid credentials', async () => {
await LoginPage.open()
await expect('pass').toBe('fail')
await LoginPage.login('tomsmith', 'SuperSecretPassword!')
await expect(SecurePage.flashAlert).toBeExisting()
await expect(SecurePage.flashAlert).toHaveTextContaining(
'You logged into a secure area!')
})
})
Run the test with npm run wdio and check the log output.
Relevant log output
PS C:\Users\cs1lrj\Documents\automation\test>npmrunwdio>wdio>wdiorun./wdio.conf.tsExecutionof1workersstartedat2024-03-15T16:28:04.585Z2024-03-15T16:28:04.622ZINFO @wdio/cli:launcher: RunonPreparehook2024-03-15T16:28:04.624ZINFO @wdio/utils: Settingupbrowserdriverfor: chrome@stable2024-03-15T16:28:04.625ZINFO @wdio/utils: Settingupbrowserbinariesfor: chrome@stable2024-03-15T16:28:04.629ZINFO webdriver: DownloadingChromedriverv122.0.6261.1292024-03-15T16:28:04.891ZWARN webdriver: Chromedriverv122.0.6261.129don't exist, trying to find known good version...2024-03-15T16:28:05.095Z INFO webdriver: Download of Chromedriver v122.0.6261.128 was successful2024-03-15T16:28:05.098Z INFO @wdio/cli:launcher: Run onWorkerStart hook2024-03-15T16:28:05.099Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,./wdio.conf.ts[0-0] 2024-03-15T16:28:08.256Z INFO @wdio/local-runner: Run worker command: run[0-0] RUNNING in chrome - file:///C:/Users/cs1lrj/Documents/automation/test/test/specs/test.e2e.ts[0-0] 2024-03-15T16:28:08.643Z INFO webdriver: Initiate new session using the WebDriver protocol[0-0] 2024-03-15T16:28:09.087Z INFO webdriver: Downloading Chromedriver v122.0.6261.129[0-0] 2024-03-15T16:28:09.335Z WARN webdriver: Chromedriver v122.0.6261.129 don'texist,tryingtofindknowngoodversion...
[0-0]2024-03-15T16:28:09.425ZINFO webdriver: DownloadofChromedriverv122.0.6261.128wassuccessful[0-0]2024-03-15T16:28:10.930ZINFO chromedriver: StartingChromeDriver122.0.6261.128(f18a44fedeb29764b2b5336c120fdd90ef1a3f5c-refs/branch-heads/6261@{#1057})onport49859[0-0]2024-03-15T16:28:10.930ZINFO chromedriver: Remoteconnectionsareallowedbyanallowlist(0.0.0.0).[0-0]2024-03-15T16:28:10.930ZINFO chromedriver: Please seehttps://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.[0-0]2024-03-15T16:28:10.937ZINFO chromedriver: ChromeDriverwasstartedsuccessfully.[0-0]2024-03-15T16:28:11.902ZINFO @wdio/utils: StartedChromedriverv122.0.6261.129withparams--port=49859--allowed-origins=*--allowed-ips=0.0.0.0in2836msonport49859[0-0]2024-03-15T16:28:12.173ZINFOwebdriver: [POST]http://0.0.0.0:49859/session[0-0]2024-03-15T16:28:12.174ZINFOwebdriver: DATA{[0-0]capabilities: {[0-0]alwaysMatch: {browserName: 'chrome','goog:chromeOptions': [Object]},[0-0]firstMatch: [{}][0-0]},[0-0]desiredCapabilities: {[0-0]browserName: 'chrome',[0-0]'goog:chromeOptions': {[0-0]binary: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'[0-0]}[0-0]}[0-0]}
DevTools listeningonws://127.0.0.1:49866/devtools/browser/4ea2b772-9fb7-479f-9cde-afcc7fb49d57[0-0]2024-03-15T16:28:14.068ZINFO webdriver: COMMANDnavigateTo("https://the-internet.herokuapp.com/login")[0-0]2024-03-15T16:28:14.070ZINFO webdriver: [POST] http://0.0.0.0:49859/session/8a5475891fea8e7f45b230a454413a79/url[0-0]2024-03-15T16:28:14.070ZINFO webdriver: DATA{url: 'https://the-internet.herokuapp.com/login'}[0-0]2024-03-15T16:28:18.442ZINFO webdriver: RESULTnull[0-0]Errorin"My Login application.should login with valid credentials"
Error: expect(received).toBe(expected)// Object.is equality
Expected: "fail"
Received: "pass"atContext.<anonymous>(file:///C:/Users/cs1lrj/Documents/automation/test/test/specs/test.e2e.ts:7:30)[0-0]2024-03-15T16:28:18.456ZINFOwebdriver: COMMANDdeleteSession()[0-0]2024-03-15T16:28:18.457ZINFOwebdriver: [DELETE]http://0.0.0.0:49859/session/8a5475891fea8e7f45b230a454413a79[0-0]2024-03-15T16:28:18.699ZINFOwebdriver: RESULTnull[0-0]2024-03-15T16:28:18.700ZINFOwebdriver: KilldriverprocesswithPID1932[0-0]FAILEDinchrome-file:///C:/Users/cs1lrj/Documents/automation/test/test/specs/test.e2e.ts2024-03-15T16:28:18.846ZINFO @wdio/cli:launcher: RunonWorkerEndhook2024-03-15T16:28:18.847ZINFO @wdio/cli:launcher: RunonCompletehook"spec" Reporter:
------------------------------------------------------------------[chrome122.0.6261.128windows #0-0]Running: chrome(v122.0.6261.128)onwindows[chrome122.0.6261.128windows #0-0]SessionID: 8a5475891fea8e7f45b230a454413a79[chrome122.0.6261.128windows #0-0][chrome122.0.6261.128windows #0-0]» \test\specs\test.e2e.ts[chrome122.0.6261.128windows #0-0]MyLoginapplication[chrome122.0.6261.128windows #0-0]✖shouldloginwithvalidcredentials[chrome122.0.6261.128windows #0-0][chrome122.0.6261.128windows #0-0]1failing(4.6s)[chrome122.0.6261.128windows #0-0][chrome122.0.6261.128windows #0-0]1)MyLoginapplicationshouldloginwithvalidcredentials[chrome122.0.6261.128windows #0-0]1)MyLoginapplicationshouldloginwithvalidcredentials[chrome122.0.6261.128windows #0-0]expect(received).toBe(expected)// Object.is equality
Expected: "fail"
Received: "pass"[chrome122.0.6261.128windows #0-0] Error: expect(received).toBe(expected)// Object.is equality[chrome122.0.6261.128windows #0-0][chrome122.0.6261.128windows #0-0] Expected: "fail"[chrome122.0.6261.128windows #0-0]Received: "pass"[chrome122.0.6261.128windows #0-0]atContext.<anonymous>(file:///C:/Users/cs1lrj/Documents/automation/test/test/specs/test.e2e.ts:7:30)SpecFiles: 0passed,1failed,1total(100%completed)in00:00:142024-03-15T16:28:18.854ZINFO @wdio/local-runner: Shuttingdownspawnedworker2024-03-15T16:28:19.111ZINFO @wdio/local-runner: Waitingfor0toshutdowngracefully2024-03-15T16:28:19.111ZINFO @wdio/local-runner: shuttingdown
Code of Conduct
I agree to follow this project's Code of Conduct
Is there an existing issue for this?
I have searched the existing issues
The text was updated successfully, but these errors were encountered:
We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!
I don't know if this will help in diagnosing the issue, but when running the same reproducible steps but staying with Javascript rather than Typescript the error line reporting works as expected. A colleague mentioned it and I've reproduced it just now.
hello, i have the same issue with my project, i am using webdriverio 8.37, node 20.11, mocha as framework, typescript as compiler, chrome as browser ...
how can i solve that without downgrade to webdriverio 7 ?
is there any news about that?
Thanks for your helps
This might get resolved with v9 where we use tsx for TypeScript compiling. Can't guarantee this though. Contributions that resolve this problem are appreciated.
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
8.33.1
Node.js Version
20.11.1
Mode
Standalone Mode
Which capabilities are you using?
No response
What happened?
When an error is encountered it is reported in the terminal as expected. However the error reporting directs to the incorrect line. When using ctrl+click on the error location VS Code goes to the same incorrect line.
In the example provided below, the error is on line 9, while the report shows it as line 7. In files with more lines of code this difference is larger.
The autogenerated wdio test with an error introduced:
![image](https://private-user-images.githubusercontent.com/149380723/313266581-cd7920ef-ebc3-4ed8-bcb9-269bcc5ee25d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNDgzNzcsIm5iZiI6MTcxOTI0ODA3NywicGF0aCI6Ii8xNDkzODA3MjMvMzEzMjY2NTgxLWNkNzkyMGVmLWViYzMtNGVkOC1iY2I5LTI2OWJjYzVlZTI1ZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNFQxNjU0MzdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YjllN2ZiMDIzNjdmZjRiYzc3OTAwODJkNmVhMGM3MzY2MTA1ODg2ZGMyYzYwNzZkYTIwYzA3YzQzMzc2ODNlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.H86Iy_GWwL7vFMgTkQ7vVQqXiIbBoDoJtoMMAxGv7LE)
The terminal output:
What is your expected behavior?
The line shown in the error should be the line in which the error occurred.
When using ctrl+click on the error it should take the user to the correct line of code.
How to reproduce the bug.
Run
npm init wdio
and select the following options:Introduce a deliberate failure to the autogenerated test file, for example:
Run the test with
npm run wdio
and check the log output.Relevant log output
Code of Conduct
Is there an existing issue for this?
The text was updated successfully, but these errors were encountered: