Skip to content

Gherkin error: defineParameterType is not defined #4549

@losyukov-leonid

Description

@losyukov-leonid

What are you trying to achieve?

I use TS + Playwright + Gherkin. When I try to add defineParameterType I just getting errors.
If I use like in the documentation:

DefineParameterType({
  name: 'popup_type',
  regexp: /critical|non-critical/,
  transformer: (match) => {
    return match === 'critical' ? '[class$="error"]' 
    : '[class$="warning"]';
  },
};);

Given('I see {popup_type} popup', (popup) => {
  I.seeElement(popup);
});

The error is :

⨯ Unable to compile TypeScript:
src/step_definitions/parameterTypes.ts:3:1 - error TS2552: Cannot find name 'DefineParameterType'. Did you mean 'defineParameterType'?

Because in node_modules/codeceptjs/typings/index.d.ts there is declaration:

declare function defineParameterType(options: CodeceptJS.IParameterTypeDefinition<any>): void

If I use like this:

defineParameterType({
  name: 'popup_type',
  regexp: /critical|non-critical/,
  transformer: (match) => {
    return match === 'critical' ? '[class$="error"]' 
    : '[class$="warning"]';
  },
};);

Given('I see {popup_type} popup', (popup) => {
  I.seeElement(popup);
});

The error is :

defineParameterType is not defined
ReferenceError: defineParameterType is not defined

And if I change in node_modules/codeceptjs/typings/index.d.ts from:

declare function defineParameterType(options: CodeceptJS.IParameterTypeDefinition<any>): void

to:

declare function DefineParameterType(options: CodeceptJS.IParameterTypeDefinition<any>): void

and use it like in the documentation everything is working properly.

What do you get instead?

Correctly working defineParameterType function.

Details

  • CodeceptJS version: 3.6.7
  • NodeJS Version: 22.11.0
  • Operating System: doesn't matter
  • Playwright version: 1.45.0
  • Configuration file:
export const config: CodeceptJS.MainConfig = {
  tests: '',
  output: './output',
  helpers: {
    Playwright: {
      browser: 'chromium',
      show: false,
      waitForNavigation: 'load',
      fullPageScreenshots: true,
      waitForTimeout: 15000
    }
  },
  gherkin: {
    features: './src/features/**/*.feature',
    steps: './src/step_definitions/*.ts'
  },
  include: {},
  require: ['ts-node/register'],
  fullPromiseBased: true
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions