Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

return the _super call #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kellyselden
Copy link

@kellyselden kellyselden commented Jun 28, 2019

When using this plugin in conjunction with chai-as-promised, you can run into issues the way you both override equal.

With code like await expect(foo).to.eventually.equal(bar)

Without this change:

     TypeError: { __flags: 
   { ssfi: [Function: overwritingMethodWrapper],
     lockSsfi: true,
     object: {},
     message: 'element: getText',
     eventually: true },
  assert: [Function],
  __methods: 
   { an: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     a: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     include: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     contain: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     contains: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     includes: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     length: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     lengthOf: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     startsWith: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     startWith: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     endsWith: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     endWith: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     equalIgnoreCase: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     equalIgnoreSpaces: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     containIgnoreSpaces: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     containIgnoreCase: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     singleLine: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     reverseOf: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     palindrome: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     entriesCount: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     indexOf: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     content: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     contents: 
      { method: [Function: overwritingChainableMethodWrapper],
        chainingBehavior: [Function: overwritingChainableMethodGetter] },
     files: { method: [Function], chainingBehavior: [Function] },
     subDirs: { method: [Function], chainingBehavior: [Function] } },
  equal: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  equals: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  eq: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  eql: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  eqls: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  above: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  gt: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  greaterThan: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  least: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  gte: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  below: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  lt: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  lessThan: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  most: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  lte: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  within: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  instanceof: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  instanceOf: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  property: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  ownProperty: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  haveOwnProperty: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  ownPropertyDescriptor: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  haveOwnPropertyDescriptor: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  match: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  matches: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  string: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  keys: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  key: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  throw: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  throws: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  Throw: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  respondTo: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  respondsTo: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  satisfy: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  satisfies: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  closeTo: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  approximately: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  members: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  oneOf: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  change: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  changes: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  increase: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  increases: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  decrease: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  decreases: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  by: { [Function: overwritingMethodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  rejectedWith: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  notify: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  become: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  callCount: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledBefore: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledAfter: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledImmediatelyBefore: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledImmediatelyAfter: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledOn: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledWith: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledOnceWith: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledWithExactly: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledOnceWithExactly: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  calledWithMatch: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  returned: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  thrown: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  basename: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  dirname: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  extname: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  path: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  file: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  schema: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  directory: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } },
  symlink: { [Function: methodWrapper] __flags: { ssfi: [Function: proxyGetter] } } } is not a thenable.
      at assertIsAboutPromise (node_modules/chai-as-promised/lib/chai-as-promised.js:31:19)
      at Assertion.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:54:13)
      at Assertion.propertyGetter (node_modules/chai/lib/chai/utils/addProperty.js:62:29)
      at Object.get (<anonymous>)
      at Object.proxyGetter [as get] (node_modules/chai/lib/chai/utils/proxify.js:98:22)
      at Context.<anonymous> (test/integration/chai-webdriver-test.js:64:52)

With this change:

✓ works (3922ms)

An interesting note, if you change the code to use eq or equals instead, it works without any changes.

I tried to reproduce this in your test suite, but failed. Partly because chai.getStyleTest doesn't support promises.

Copy link
Member

@JamesMessinger JamesMessinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! A nice, simple fix 👍

@kellyselden kellyselden force-pushed the return branch 3 times, most recently from b12dee1 to 9939674 Compare July 1, 2019 18:32
@kellyselden
Copy link
Author

The lockfile had an inconsistency, so I fixed that and now the tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants