Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed step in tryTo causes it to look like the source of failure in trace of steps #4619

Open
hxllv opened this issue Nov 29, 2024 · 1 comment

Comments

@hxllv
Copy link

hxllv commented Nov 29, 2024

What are you trying to achieve?

We have a test that utilizes tryTo to resolve some flakiness with our app. During migration to playwright, test started failing and it looked like the reason for it was the step inside tryTo. However under close inspection that was not the reason that the test failed, it was instead something else later down the test.

What do you get instead?

I made this env separately to showcase the issue. The test fails because .nocheckboxishere was not found, but looking at the trace of scenario steps, it give the illusion that the check within tryTo for .doesntexist is the cause.

npm run codeceptjs

> [email protected] codeceptjs
> codeceptjs run --steps

CodeceptJS v3.6.7 #StandWithUkraine
Using test root "/Users/nacetavcer/ccjs"

tryTo --
  test something
    I am on page "https://codecept.io/quickstart/"
    I see element ".doesntexist"
false
    I fill field "#algolia-search-input", "codecept"
    I press key "Enter"
    I see "CodeceptJS"
    I see checkbox is checked ".nocheckboxishere"
  ✖ FAILED in 3271ms


-- FAILURES:

  1) tryTo
       test something:
     Checkable ".nocheckboxishere" was not found by text|CSS|XPath
      at new ElementNotFound (node_modules/codeceptjs/lib/helper/errors/ElementNotFound.js:15:11)
      at assertElementExists (node_modules/codeceptjs/lib/helper/Playwright.js:3742:11)
      at Playwright.proceedIsChecked (node_modules/codeceptjs/lib/helper/Playwright.js:3604:3)
  
  Scenario Steps:
  - I.seeElement(".doesntexist") at ./tryTo_test.js:5:42
  - I.amOnPage("https://codecept.io/quickstart/") at Test.<anonymous> (./tryTo_test.js:4:7)
  
  Artifacts:
  - screenshot: /Users/nacetavcer/ccjs/output/test_something.failed.png


  FAIL  | 0 passed, 1 failed   // 4s

Provide test source code if related

Feature('tryTo');

Scenario('test something', async ({ I }) => {
    I.amOnPage('https://codecept.io/quickstart/')
    const result = await tryTo(() => { I.seeElement('.doesntexist') })

    console.log(result)

    I.fillField('#algolia-search-input', 'codecept')
    I.pressKey('Enter')
    I.see('CodeceptJS')
    I.seeCheckboxIsChecked('.nocheckboxishere')
});

Details

  • CodeceptJS version: 3.6.7
  • NodeJS Version: 23.3.0
  • Operating System: macOS 15.1.1
  • Configuration file:
const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

/** @type {CodeceptJS.MainConfig} */
exports.config = {
  tests: './*_test.js',
  output: './output',
  helpers: {
    Playwright: {
      browser: 'chromium',
      url: 'http://google.com',
      show: true
    }
  },
  include: {
    I: './steps_file.js'
  },
  name: 'ccjs'
}
@incoming-th
Copy link

This may be related to my issue - still waiting for fix - where the tryTo() is throwing error in logs and the recorder falsy thinks it's a failure.

#4516

The issue could be in the tryTo() module or how the recorder parse the errors. Still no fix as of today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants