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

CodeceptJs passes test when unknown methode #4606

Open
deinlieblingskevin opened this issue Nov 19, 2024 · 6 comments
Open

CodeceptJs passes test when unknown methode #4606

deinlieblingskevin opened this issue Nov 19, 2024 · 6 comments

Comments

@deinlieblingskevin
Copy link

What are you trying to achieve?

First off: we could manage to archieve autocompletion in our ide
So there can be some mistakes while writing a test. like in this example my coworker had a spelling in a method which lead to a passing test, even though it was all not valid (text was not there, button was not pressed).
We tried to call a methode that definitly doesnt exist. "sfslfdsflkds" and if we do so, the test always passes.
can we change this behaviour to failing? or an error message or something?

What do you get instead?

Error message or failing test or something related..

CodeceptJS v3.1.1
Using test root "C:\dev\TestConnectSuite\Frontend"
 
@SapInputMaskTom --
  √ Approve SAP Test parameter in 17907ms
 
  OK  | 1 passed   // 21s
Execution time (hr): 20s 728.7074ms

Provide test source code if related

I.sfslfdsflkds();
I.see('somethingNotthere')
I.seeElement(....) // unkown element, which is definitly not there

Details

  • CodeceptJS version: v3.1.1
  • NodeJS Version: 14.16
  • Operating System: Windows
  • puppeteer
  • Configuration file:
const {setHeadlessWhen} = require('@codeceptjs/configure');

const testFolder = './e2e/pages';
const fs = require('fs');

let include = fs.readdirSync(testFolder)
    // get access to file and path
    .map(file => ({file, path: file}))
    // replace snake case to camel case
    .map(({file, path}) => ({file: file.replace(/([-_]\w)/g, g => g[1].toUpperCase()), path}))
    // remove .js extension
    .map(({file, path}) => ({file: file.slice(0, -3), path}))
    // convert to object with key as file + "Page", value as "file location"
    .reduce((obj, {file, path}) => (obj[`${file}Page`] = `${testFolder}/${path}`, obj), {});
include = {I: './e2e/steps/steps_file.js', ...include};

// turn on headless mode when running with HEADLESS=true environment variable
// HEADLESS=true npx codecept run
setHeadlessWhen(process.env.HEADLESS);

exports.config = {
    tests: './e2e/tests/*_test.js',
    output: './e2e/output/',
    helpers: {
        Puppeteer: {
            url: process.env.profile,
            show: true,
            waitForNavigation: 'networkidle0',
            waitForAction: 500,
            smartWait: 10000,
            getPageTimeout: 0,
            windowSize: '1280x960',
            chrome: {
                executablePath: 'C:/Program Files/Chromium/Application/chrome.exe',
                args: ['--window-size=1280,1080'],
                defaultViewport: {
                    width: 1280,
                    height: 960
                }
            },
        },
    },
    include,
    mocha: {
        "reporterOptions": {
            "codeceptjs-cli-reporter": {
                "stdout": "-",
                "options": {
                    "verbose": false,
                    "steps": true
                }
            },
            "mocha-junit-reporter": {
                "stdout": "./output/console.log",
                "options": {
                    "mochaFile": "./e2e/output/result.xml"
                }
            }
        }
    },
    name: 'Frontend',
    plugins: {
        retryFailedStep: {
            enabled: true
        },
        screenshotOnFail: {
            enabled: true
        },
        pauseOnFail: {
            enabled: false
        },
        tryTo: {
            enabled: true
        }
    },
    bootstrap: require('./e2e/hooks/bootstrap.js'),
    teardown: require('./e2e/hooks/teardown.js')
}
@kobenguyent
Copy link
Collaborator

hi @deinlieblingskevin may you happen to reproduce the same issue with latest version?

@deinlieblingskevin
Copy link
Author

its a big software and right now we cannot upgrade. maybe in january we will be able to do so and try the latest version

@kobenguyent
Copy link
Collaborator

its a big software and right now we cannot upgrade. maybe in january we will be able to do so and try the latest version

thanks for your prompt reply! My guess is that using TS would prevent us from having this kinda issue.

@deinlieblingskevin
Copy link
Author

thanks for the fast answer. how much efford is it to switch to typescript?

@kobenguyent
Copy link
Collaborator

thanks for the fast answer. how much efford is it to switch to typescript?

https://codecept.io/typescript/#getting-started
I could not say for sure. But as the documentation, it doesn't sound much complicated.

@deinlieblingskevin
Copy link
Author

Thanks a @kobenguyent, i tried it on a spike to switch to ts and its really helpful! <3

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