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

[Bug]: #12672

Closed
kpeters-cbsi opened this issue Apr 14, 2022 · 3 comments · Fixed by #12674
Closed

[Bug]: #12672

kpeters-cbsi opened this issue Apr 14, 2022 · 3 comments · Fixed by #12674
Labels

Comments

@kpeters-cbsi
Copy link

Version

27.5.1

Steps to reproduce

  1. Clone repo at https://github.com/kpeters-cbsi/jest-fails-to-mock-selenium-webdriver
  2. yarn install
  3. yarn test

Expected behavior

I expect the test to complete successfully.

Actual behavior

 FAIL  test/index.ts
  ● Test suite failed to run

    TypeError: name.startsWith is not a function

      at ModuleMocker._createMockFunction (node_modules/jest-mock/build/index.js:594:22)
          at Array.forEach (<anonymous>)

Additional context

I did a bit of debugging on my own, and I think this is happening in _createMockFunction:

    if (name && name.startsWith(boundFunctionPrefix)) { <--- HERE
      do {
        name = name.substring(boundFunctionPrefix.length);
        // Call bind() just to alter the function name.
        bindCall = '.bind(null)';
      } while (name && name.startsWith(boundFunctionPrefix));
    }

Something in selenium-webdriver has a name property that's a function, rather than a string, which is causing that error. I wasn't able to figure out which class in selenium-webdriver was the culprit, however.

Environment

System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
    Yarn: 3.2.0 - ~/.nvm/versions/node/v14.19.0/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v14.19.0/bin/npm
  npmPackages:
    jest: ^27.5.1 => 27.5.1
@SimenB
Copy link
Member

SimenB commented Apr 19, 2022

https://github.com/facebook/jest/releases/tag/v28.0.0-alpha.9

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants