Skip to content

retryFailedStep is not disabled in tryTo code blocks, in the latest version of codeceptJS #4021

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

Closed
ZhangXuedan opened this issue Nov 23, 2023 · 2 comments · Fixed by #4022
Closed

Comments

@ZhangXuedan
Copy link

What are you trying to achieve?

I think retryFailedStep should be disabled in TryTo block ,but when I use the laster version of CodeceptJS , retryFailedStep works fine in Tryto block.

What do you get instead?

image

image

image

Details

  • CodeceptJS version: 3.5.7
  • NodeJS Version: v20.3.1
  • Operating System: macos 13.4.1
  • appium 2.0.0-rc.4
  • Configuration file:
    // load env variables - this should be the first line of config
    require('dotenv-extended').config({
    path: './tests/acceptance/config/codecept.dev.env',
    defaults: './tests/acceptance/config/codecept.env',
    });
    require('ts-node/register');

const { configure, cleanReports } = require('codeceptjs-configure');
const REPORT_OUTPUT_DIR = './tests/acceptance/report';

let conf = {
name: 'Rakuma E2E Sanity Android Test',
// tests: './tests/acceptance/specs//.spec.ts',
output: REPORT_OUTPUT_DIR,

bootstrap: (callback) => {
    cleanReports({ path: REPORT_OUTPUT_DIR, relativePath: '/', callback });
},
retry: 1,
timeout: 300,
helpers: {
    driver_helper: {
        require: './tests/acceptance/helpers/driver.helper',
    },
    PlaywrightHelper: {
        require: 'codeceptjs-configure/lib/helpers/playwright.helper.js',
    },
    Appium: {
        appiumV2: true,
        platform: "Android",
        port:4724,
        path: '/',
        desiredCapabilities: {
            'automationName': "UiAutomator2",
            'appPackage': "",
            'appActivity': "",
            //appWaitActivity:"",
            'noReset': true,
            'forceAppLaunch': true,
            'newCommandTimeout': 60000, 
            'appWaitDuration': 60000,
            'deviceReadyTimeout': 60000,
            'printPageSourceOnFindFailure': true,
            'chromedriverUseSystemExecutable': true,
        }
    },

    ChaiWrapper: {
        require: 'codeceptjs-chai',
        // require: 'codeceptjs-assert',
    },
    DataHelper: {
        require: './tests/acceptance/helpers/data.helper',
    },
    HostHelper: {
        require: './tests/acceptance/helpers/host.helper',
        env: process.env.TEST_ENVIRONMENT,
        tax:process.env.TAX,
    },
    BrowserHelper: {
        require: './tests/acceptance/helpers/browser.helper',
    },
    Playwright: {
        timeout:15000,
        chromium: {
        }
    },
    GraphQLDataFactory: {
        //endpoint: 'http://10.48.60.12:8848/v1/graphql',
         endpoint: 'http://localhost:8848/v1/graphql',
        cleanup: true,
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'X-Hasura-Admin-Secret': 'cloveradminsecretkey'
        },
        factories: {
            createItemForUserById: {
                query: `mutation createItemForUserById($userId: String!, $itemInfo: ItemInfoBody) {
                    createItemForUserById(userId: $userId, itemInfo:$itemInfo) {
                        brand
                        carriage
                        catagories
                        category
                        deliveryArea
                        deliveryDate
                        deliveryMethod
                        detail
                        id
                        name
                        pcUrl
                        requestRequired
                        sellPrice
                        size
                        status
                        userId
                        itemHash
                    }
                  }`,
                factory: 'tests/acceptance/factories/items',
                revert: (data) => ({
                    query: `mutation deleteItem($userId: String!, $itemId: String!) {
                        deleteItemForUser(params: {item_id: $itemId, user_id: $userId}) {
                          item_id
                        }
                      }`,
                    variables: { userId: data.userId, itemId: data.id},
                }),
            },
            getAvaliableUser: {
                query: `mutation getAvaliableUser($count: Int!, $options: UserOptions) {
                    getAvaliableUser(params: {count: $count, options: $options}) {
                      users {
                        user_id
                        password
                        email
                        auth_token
                        name
                        session_id
                      }
                    }
                  }`,
                factory: 'tests/acceptance/factories/users',
                revert: (data) => ({
                    query: `mutation releaseUsers($ids: [String!]) {
                        releaseUsers(params: {user_ids: $ids}) {
                          effect_rows
                        }
                      }`,
                    variables: { ids: data.users.map(ele => ele.user_id) },
                }),
            },
        }
    },
    GraphQL: {
         endpoint: 'http://localhost:8848/v1/graphql',
        defaultHeaders: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'X-Hasura-Admin-Secret': 'cloveradminsecretkey'
        },
    },
    REST: {
        endpoint: 'https://internal-tenant.userfirst.jp/',
        prettyPrintJson: true,
        //   onRequest: (request) => {
        //   request.headers.auth = '123';
    },
    FileSystem: {},
},
multiple: {
    localcombo: {
        browsers: [
            {
                browser: 'firefox',
            }
        ]
    }
},
include: {
    I: './custom_steps.ts',
    sideBar: './tests/acceptance/components/sidebar.ts',
    mediaList: './tests/acceptance/components/media-list.ts',
    header: './tests/acceptance/components/header.ts',
},
plugins: {
    tryTo: {
        enabled: true,
    },
    retryTo: {
        enabled: true,
        pollInterval: 2000,
    },
    wdio: {
        enabled: false,
        services: ['appium']
    },
    retryFailedStep: {
        enabled: true,
        retries: 5,
    },
    rerun:{
        minSuccess: 10,
        maxReruns: 10
    },
    allure: {
        enabled: true,
        require: '@codeceptjs/allure-legacy',
    }
}

};

exports.config = configure.create(conf);

@cjhille
Copy link
Contributor

cjhille commented Jan 8, 2024

@kobenguyent quick question: what is the reasoning behind disabling retryFailedStep if tryTo is enabled?

the way i see it: the main benefit of retryFailedStep is a convenient way to write less verbose code and get more leeway in timing sensitive scenarios. for instance, when clicking a submit button in a dynamically validated form, one would usually have to wait until the submit button gets enabled (I.waitForEnabled). instead, i can just click it and rely on the retries no matter how long the form validation takes. why shouldn't this approach of writing tests apply tryTo blocks?

@kobenguyent
Copy link
Collaborator

I guess the nature of tryTo is to return true/false immediately of a given step and won't fail the test.

And let's say there is "Accept Cookie" banner which may surprisingly appear on a page. You use tryTo to handle test better and don't want your test to fail unexpectedly yet to retry multiple times to make sure the banner either appears or not right?

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

Successfully merging a pull request may close this issue.

3 participants