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

fix: disable retryFailedStep when using with tryTo #4022

Conversation

kobenguyent
Copy link
Collaborator

Motivation/Description of the PR

...
    tryTo: {
      enabled: true
    },
    retryFailedStep: {
      enabled: true,
      retries: 2,
    },
....

// Running tests
Plugins: screenshotOnFail, customLocator, tryTo, retryFailedStep, commentStep, autoLogin

My --
    [1]  Starting recording promises
    Timeouts: 
 › [Session] Starting singleton browser session
  Assert @C3
    --- STARTED "before each" hook: Before for "Assert @C3" ---
 › Cannot save user session with empty cookies from auto login's fetch method
    I am on page "https://google.com"
    --- ENDED "before each" hook: Before for "Assert @C3" ---
    I am on page "https://demo.playwright.dev/api-mocking"
    I see "Welcome"
    [1] <tryTo> Error | Error
 › Unsuccessful try > expected web application to include "Welcome"
  ✔ OK in 568ms


  OK  | 1 passed   // 3s

Applicable plugins:

  • tryTo
  • retryFailedStep

Type of change

  • 🐛 Bug fix

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

@kobenguyent kobenguyent merged commit 1936b0b into 3.x Nov 29, 2023
12 checks passed
@kobenguyent kobenguyent deleted the 4021-retryfailedstep-is-not-disabled-in-tryto-code-blocks-in-the-latest-version-of-codeceptjs branch November 29, 2023 06:10
@mirao
Copy link
Contributor

mirao commented Dec 11, 2023

@kobenguyent , the solution doesn't work. When the plugin tryTo is enabled for a project, the plugin retryFailedStep doesn't work at all.
Tested with CodeceptJS 3.5.10.

config:

export const config: CodeceptJS.MainConfig = {
    tests: "./*_test.ts",
    output: "./output",
    helpers: {
        Playwright: {
            browser: "chromium",
            url: "http://localhost",
            show: true,
        },
    },
    name: "my",
    plugins: {
        tryTo: {
            enabled: true,
        },
        retryFailedStep: {
            enabled: true,
        },
    },
};

test:

Feature("My");

Scenario("test something", ({ I }) => {
    I.amOnPage("https://www.google.com");
    I.click("my_locator");
});

output in verbose mode shows that the plugin retryFailedStep doesn't do any attempt 🐛

My --
    [1]  Starting recording promises
    Timeouts: 
 › [Session] Starting singleton browser session
  test something
    I am on page "https://www.google.com"
    › [Browser:Info] Autofocus processing was blocked because a document already has a focused element.
    › [Browser:Error] Permissions policy violation: unload is not allowed in this document.
    I click "my_locator"
    [1] Error (Non-Terminated) | Error: Clickable element "my_locator" was not found by text|CSS|XPath | (err) => { step.status = 'failed'; step.endTime = ...
    [1] Error | Error: Clickable element "my_locator" was not found by text|CSS|XPath undefined...
    [1] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, try to save a screenshot
 › Screenshot is saving to /home/mirao/workspace/codeceptjs/tests/my/output/test_something.failed.png
  ✖ FAILED in 1187ms

If you disable or remove the tryTo plugin from the config, it works well (the plugin retryFailedStep will start working ✔️ )
output in verbose mode:

My --
    [1]  Starting recording promises
    Timeouts: 
 › [Session] Starting singleton browser session
  test something
    I am on page "https://www.google.com"
    › [Browser:Info] Autofocus processing was blocked because a document already has a focused element.
    › [Browser:Error] Permissions policy violation: unload is not allowed in this document.
    I click "my_locator"
    [1] Retrying... Attempt #2
    [1] Retrying... Attempt #3
    [1] Retrying... Attempt #4
    [1] Error (Non-Terminated) | Error: Clickable element "my_locator" was not found by text|CSS|XPath | (err) => { step.status = 'failed'; step.endTime = ...
    [1] Error | Error: Clickable element "my_locator" was not found by text|CSS|XPath undefined...
    [1] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, try to save a screenshot
 › Screenshot is saving to /home/mirao/workspace/codeceptjs/tests/my/output/test_something.failed.png
  ✖ FAILED in 2641ms

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

Successfully merging this pull request may close these issues.

retryFailedStep is not disabled in tryTo code blocks, in the latest version of codeceptJS
3 participants