Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Gherkin error: defineParameterType is not defined #4549

Closed
losyukov-leonid opened this issue Nov 9, 2024 · 0 comments · Fixed by #4548
Closed

Gherkin error: defineParameterType is not defined #4549

losyukov-leonid opened this issue Nov 9, 2024 · 0 comments · Fixed by #4548

Comments

@losyukov-leonid
Copy link

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
};
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant