CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Regression to dependency injection for function style page objects

Open jlp-craigmorten opened this issue 1 year ago • 1 comments

In one of our projects we make use of page objects similar that use a function style, e.g.

const fields = {
  increaseButton: { css: 'button[data-testid="increase"]' },
  // ... rest of code
};

module.exports = () => name => ({
  element: `section [data-test-name="${name}"]`,

  increaseItem() {
    within(this.element, () => {
      I.waitAndClick(fields.increaseButton);
    });
  },

  // ... rest of code
});

Where it is used as follows:

Scenario('Example Test', ({ Tile }) => {
  const tile = Tile('Example Name');
  tile.increaseItem();

  // ... rest of code

These page objects are pulled in as documented via the include option in the codecept.conf.ts config files.

This has been working fine up to 3.6.10 but appears to have regressed in the 3.7.0 - 3.7.2 version range where we now see the following error:

1) Example Scenario
     Example Test:
   
Tile is not a function
TypeError: 
    at Test.<anonymous> (functional-tests/example/example-test.js:34:22)
    at Context.test.fn (node_modules/codeceptjs/lib/mocha/asyncWrapper.js:100:14)

It seems that other styles of page object are unimpacted.

jlp-craigmorten avatar Mar 18 '25 09:03 jlp-craigmorten

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Jun 17 '25 03:06 github-actions[bot]