Skip to content

Regression to dependency injection for function style page objects #4928

Open
@jlp-craigmorten

Description

@jlp-craigmorten

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions