Skip to content

require.resolve is not a function when using jest.mock #692

Closed

Description

Activity

  1. CompuIves commented on Apr 4, 2018

    @CompuIves
    Contributor

    Ahh, yes good one. We need to build jest.mock support since we use our own resolver and executor for modules.

    I will try to build this this week, regardless I'll keep this issue open for everyone to pickup in the meantime.

    We need to get all jest.mock calls and add them to the aliases field on Manager. I think that should do the trick and make jest.mock work.

  2. FDiskas commented on Apr 5, 2018

    @FDiskas
    ContributorAuthor

    jest.spyOn is another one :)

  3. the0neWhoKnocks commented on May 18, 2018

    @the0neWhoKnocks

    Not sure if it's related, but I'm seeing similar behavior with enzyme. I have a jest.config.js file that works fine locally but seems to be ignored in the sandbox. When I inline the jest config into the package.json it still doesn't load the setupTestFrameworkScriptFile or setupFiles files. So I then tried to add the enzyme configuration code at the top of my test files and got more errors. Here's the URL to the import of my repo https://codesandbox.io/s/github/the0neWhoKnocks/app-console/tree/master/

    I didn't find anything regarding enzyme in the issues, but after reading that you have to build support for frameworks, maybe enzyme also needs to be added to the pile.

    jest.useFakeTimers() doesn't work either.

    In the meantime, is there a way to disable tests in the sandbox?

  4. the0neWhoKnocks commented on May 21, 2018

    @the0neWhoKnocks

    @FDiskas yeah I tried that, but that's not a solution when jest has setupTestFrameworkScriptFile built in. Also, even after doing that, a lot of tests didn't work due to the usage of mock and useFakeTimers. It'd be nice if in the meantime, codesandbox would display a message saying "sorry, these testing features aren't available" or "these tests have been disabled due to lack of api support". Something along those lines so consumers don't waist time debugging their code. Honestly I'd be fine with the ability to just toggle tests off, I saw there was a way to toggle watching of files off, but the tests would still run at least once throwing inaccurate errors.

  5. FDiskas commented on May 21, 2018

    @FDiskas
    ContributorAuthor

    @the0neWhoKnocks so lets wait for #513

  6. github-actions commented on Sep 4, 2020

    @github-actions

    This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

  7. github-actions commented on Oct 1, 2020

    @github-actions

    This issue has been automatically closed because there wasn't any activity after the previous notice or the stale label wasn't removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions