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

Cannot find module '_isMockFunction' #175548

Closed
idahogurl opened this issue Feb 27, 2023 · 5 comments
Closed

Cannot find module '_isMockFunction' #175548

idahogurl opened this issue Feb 27, 2023 · 5 comments
Assignees
Labels
extension-host Extension host issues info-needed Issue requires more information from poster

Comments

@idahogurl
Copy link

idahogurl commented Feb 27, 2023

Description

Starting with VS Code 1.74.1, I get the following error when running tests using Jest. It works with VS Code 1.73.1

 Cannot find module '_isMockFunction'
    Require stack:
    - /Users/Rebecca.Vest/dev/vs-code-prettier-eslint/.vscode-test/vscode-darwin-arm64-1.74.1/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
    - /Users/Rebecca.Vest/dev/vs-code-prettier-eslint/.vscode-test/vscode-darwin-arm64-1.74.1/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js

Reproduction

  1. Clone https://www.github.com/idahogurl/vs-code-prettier-eslint
  2. Run yarn to install node modules
  3. Run yarn test

This may be a VS Code issue.

@idahogurl idahogurl changed the title _isMockFunction Cannot find module '_isMockFunction' Feb 27, 2023
@connor4312
Copy link
Member

connor4312 commented Feb 27, 2023

This is caused by Jest trying to check a property on every global. Which is questionable in a world where WeakSet exists. That is then triggers a proxy getter and causes this error.

image

@alexdima not sure if you want to do anything here

@connor4312 connor4312 transferred this issue from microsoft/vscode-test Feb 27, 2023
@alexdima alexdima assigned jrieken and unassigned alexdima Feb 27, 2023
@JustinGrote
Copy link
Contributor

@idahogurl downgrading to Jest 27.5.1 fixed this for me, I don't know specifically what version this got added in but a revert does fix it.

@rbuckton
Copy link
Member

rbuckton commented Jun 8, 2023

I put together a PR to work around this for jest: jestjs/jest#14188

I also have a workaround you can do locally. In your start.ts (or whatever script you point to with --extensionTestsPath), add the following lines to the top of the file:

declare global {
    var _VSCODE_NODE_MODULES: any;
}

if (globalThis._VSCODE_NODE_MODULES) {
    globalThis._VSCODE_NODE_MODULES = new Proxy(globalThis._VSCODE_NODE_MODULES, {
        get(target, p, receiver) {
            if (p === "_isMockFunction") return undefined;
            return Reflect.get(target, p, receiver);
        }
    });
}

This wraps the _VSCODE_NODE_MODULES proxy with one that simply returns undefined for _isMockFunction.

@jrieken jrieken added the extension-host Extension host issues label Jun 29, 2023
@jrieken
Copy link
Member

jrieken commented Dec 6, 2023

Did this get fixed in jest or is this still an issue?

@jrieken jrieken added the info-needed Issue requires more information from poster label Dec 6, 2023
@VSCodeTriageBot
Copy link
Collaborator

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extension-host Extension host issues info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

8 participants