CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Deprecation Warning: 'tryTo'/'retryTo' is present though the plugins are not set in config

Open mirao opened this issue 10 months ago • 5 comments

mirao@jobr:~/workspace/my$ codeceptjs run
Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.
Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.
CodeceptJS v3.7.2 #StandWithUkraine
Using test root "/home/mirao/workspace/my"

My --
  ✔ test something in 582ms

  OK  | 1 passed   // 938ms

Test

Feature('My');

Scenario('test something',  ({ I }) => {
    I.amOnPage('https://www.google.com');
    I.see('Google');
});

TS config

import { setHeadlessWhen, setCommonPlugins } from '@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();

export const config: CodeceptJS.MainConfig = {
  tests: './*_test.ts',
  output: './output',
  helpers: {
    Playwright: {
      browser: 'chromium',
      url: 'http://localhost',
      show: true
    }
  },
  include: {
    I: './steps_file'
  },
  name: 'my'
}

Used SW:

  • CodeceptJS 3.7.2
  • Playwright 1.50.1
  • NodeJS 22
  • Ubuntu 24.04

mirao avatar Feb 13 '25 08:02 mirao

Oh, that's interesting, CodeceptJS 3.7 introduced codeceptjs/effects (link)!

Which is supposed to move tryTo and retryTo from plugins to a single module.

djyarber avatar Feb 14 '25 21:02 djyarber

I could not reproduce this with my conf, thou

const { setHeadlessWhen } = require('@codeceptjs/configure');

setHeadlessWhen(process.env.HEADLESS);

exports.config = {
  tests: './todomvc-tests/**/*_test.js',
  output: './output',
  helpers: {
    Playwright: {
      url: 'http://localhost',
      waitForTimeout: 5000,
      show: false,
    },

    REST: {},

    CustomHelper: {
      require: './todomvc-tests/helpers/custom.helper.js'
    }
  },

  gherkin: {
    features: './todomvc-tests/features/*.feature',
    steps: [
      './todomvc-tests/step-definitions/create-todos.steps.js'
    ]
  },

  include: {
    TodosPage: './todomvc-tests/pages/todos.page.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'codecept demo tests'
}
➜  helloworld npm run codeceptjs:demo

> [email protected] codeceptjs:demo
> codeceptjs run -c node_modules/@codeceptjs/examples

CodeceptJS v3.7.2 #StandWithUkraine
Using test root "/Users/t/Desktop/helloworld/node_modules/@codeceptjs/examples"

Create Todos with BDD --
  ✔ Create a single todo item @bdd in 3343ms
codepress demo --
^C%      

kobenguyent avatar Mar 05 '25 15:03 kobenguyent

@kobenguyent Still I'm able to reproduce it. Just create a new folder, cd there, run npx create-codeceptjs ., then npx codeceptjs init and create a project in TypeScript. You get the warning even during initialization of a project

mirao@rog:~/workspace/my$ npx codeceptjs init

  Welcome to CodeceptJS initialization tool
  It will prepare and configure a test environment for you

 Useful links:

  👉 How to start testing ASAP: https://codecept.io/quickstart/#init
  👉 How to select helper: https://codecept.io/basics/#architecture
  👉 TypeScript setup: https://codecept.io/typescript/#getting-started

Installing to /home/mirao/workspace/my
? Do you plan to write tests in TypeScript? Yes
? Where are your tests located? ./*_test.ts
? What helpers do you want to use? Playwright
? Where should logs, screenshots, and reports to be stored? ./output
? Do you want to enable localization for tests? http://bit.ly/3GNUBbh English (no localization)
Configure helpers...
? [Playwright] Browser in which testing will be performed. Possible options: chromium, firefox, webkit or electron 
chromium
? [Playwright] Base url of site to be tested http://localhost
? [Playwright] Show browser window Yes

Steps file created at ./steps_file.ts
Config created at /home/mirao/workspace/my/codecept.conf.ts
Directory for temporary output files created at './output'
Installing packages:  typescript, ts-node, @types/node

up to date, audited 950 packages in 758ms

125 packages are looking for funding
  run `npm fund` for details

14 vulnerabilities (4 low, 4 moderate, 6 high)

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.
Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.
TypeScript Definitions provide autocompletion in Visual Studio Code and other IDEs
Definitions were generated in steps.d.ts

 Almost ready... Next step:
Creating a new test...
----------------------
? Feature which is being tested (ex: account, login, etc) My
? Filename of a test My_test.ts
Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.
Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.

Test for My_test.ts was created in /home/mirao/workspace/my/My_test.ts

--
CodeceptJS Installed! Enjoy supercharged testing! 🤩
Find more information at https://codecept.io

and also if you run a test

mirao@rog:~/workspace/my$ codeceptjs run
Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.
Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.
CodeceptJS v3.7.2 #StandWithUkraine
Using test root "/home/mirao/workspace/my"

My --
  ✔ test something in 3ms

  OK  | 1 passed   // 242ms

Tested with CodeceptJS 3.7.2, NodeJS 22.13.1

mirao avatar Mar 05 '25 16:03 mirao

Hello, same here with a new project. I follow.

L4m3-DucK avatar Apr 14 '25 16:04 L4m3-DucK

I also get these deprecation warnings.

I tried to look for tryTo/retryTo usage in my project and could not find anything. However, I came across this in my codecept.conf.ts.

setCommonPlugins();

Once I commented it out, the warnings were gone. Luckily for me, I do not use any of the common plugins enabled globally by this function.

This function enables a few plugins globally, including tryTo and retryTo. setCommonPlugins() Documentation

The default config created by npx codeceptjs init has setCommonPlugins() from the start, so unless removed manually, a new project will see these warnings.

It looks like tryTo and retryTo were moved to effects but they are still enabled as plugins in setCommonPlugins() function in codeceptjs/configure.

apatelia avatar Jun 16 '25 09:06 apatelia

@apatelia Thanks, good point. Yes, for the project created by npx codeceptjs init it's caused by the setCommonPlugins().

If I test it in our production project where we have enabled the plugins directly in codecept.conf.ts, it works as expected - I'm getting the warning only if the plugin(s) tryTo/retryTo are enabled ✅ .

Closing the issue. I guess that in CodeceptJS 4.0 the method setCommonPlugins() will be adjusted so that the two plugins won't be enabled there - it should be solved in another task.

mirao avatar Jun 20 '25 10:06 mirao