Testcafe-hammerhead: Transformer post-message-get can create invalid Javascript

Created on 30 Jun 2017  路  4Comments  路  Source: DevExpress/testcafe-hammerhead

Short Description

I encountered a bug with testcafe-hammerhead, or more precicely, this transform:

https://github.com/DevExpress/testcafe-hammerhead/blob/master/src/processing/script/transformers/post-message-get.js

This transform produces invalid Javascript when we have an object method of the name postMessage on a plain object, and that code is transpiled by babel (preset used:babel-preset-env) and bundled with webpack.

While the code runs well without testcafe, when accessed through testcafe running a fixture, it turns this:

/* harmony default export */ __webpack_exports__["default"] = ({

  methods: {
    postMessage: function postMessage(event) {
      console.log('Hello!');
    }
  }
});

into this:

/* harmony default export */ __webpack_exports__["default"] = ({

  methods: {
    postMessage: function  __get$PostMessage(null,postMessage)(event) {
      console.log('Hello!');
    }
  }
});

However, this doesn't seem to happen when the code is not bundled with webpack.

Demo reproduction Repository

https://github.com/LinusBorg/testcafe-hammerhead-postMessage-bug

The repository's README has more information and detailed instructions about how to reproduce the behaviour.

!IMPORTANT! Auto-locked resource processing bug

Most helpful comment

Happy to help :)

Thanks for a great tool!

All 4 comments

Hi @LinusBorg,
Thanks for the detailed description. I'm working on this.

Happy to help :)

Thanks for a great tool!

I'll delete my repo. If you need it again, let me know.

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

Was this page helpful?
0 / 5 - 0 ratings