- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 750
Closed
Description
Steps:
Run this TypeScript test in 3.7.x (https://codecept.io/effects.html#usage-with-typescript says that it should work)
Feature("My");
import { tryTo } from "codeceptjs/effects";
Scenario("test something", async ({ I }) => {
  I.amOnPage("https://example.com");
  // inside a test
  const success = await tryTo(() => {
    // These steps may fail but won't stop the test
    I.see("Example Domain2");
  });
  
  if (!success) {
    I.say("The text 'Example Domain2' was not found, but the test continues.");
  }
});with this config (note global plugins are disabled because they are deprecated, see https://codecept.io/effects.html#installation)
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: 'tmp'
}Expected result:
- The test passes
Actual result:
- Unable to compile TS
mirao@jobr-ubuntu:~/tmp$ npx codeceptjs run My_test.ts --verbose
***************************************
nodeInfo:  20.19.0
osInfo:  Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
cpuInfo:  (16) x64 AMD Ryzen 9 7940HS w/ Radeon 780M Graphics
chromeInfo:  136.0.7103.113
edgeInfo:  "N/A"
firefoxInfo:  undefined
safariInfo:  N/A
playwrightBrowsers:  "chromium: 136.0.7103.25, firefox: 137.0, webkit: 18.4"
If you need more detailed info, just run this: npx codeceptjs info
***************************************
TSError: ⨯ Unable to compile TypeScript:
My_test.ts:3:23 - error TS2307: Cannot find module 'codeceptjs/effects' or its corresponding type declarations.
3 import { tryTo } from "codeceptjs/effects";
                        ~~~~~~~~~~~~~~~~~~~~
    at createTSError (/home/mirao/tmp/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/home/mirao/tmp/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
    at Object.require.extensions.<computed> [as .ts] (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1096:12)
    at Module.require (node:internal/modules/cjs/loader:1298:19)
⨯ Unable to compile TypeScript:
My_test.ts:3:23 - error TS2307: Cannot find module 'codeceptjs/effects' or its corresponding type declarations.
3 import { tryTo } from "codeceptjs/effects";
                        ~~~~~~~~~~~~~~~~~~~~
TSError: 
    at createTSError (/home/mirao/tmp/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/home/mirao/tmp/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
    at Object.require.extensions.<computed> [as .ts] (/home/mirao/tmp/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1096:12)
    at Module.require (node:internal/modules/cjs/loader:1298:19)
Woarkound: (helped by GitHub Copilot)
- Create types/codeceptjs-effects.d.tswith this content
// Type definitions for codeceptjs/effects
declare module "codeceptjs/effects" {
  export function tryTo(fn: () => void | Promise<void>): Promise<boolean>;
}Used SW:
- CodeceptJS 3.7.3
- Playwright 1.52
Metadata
Metadata
Assignees
Labels
No labels