{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/6066","repository_url":"https://api.github.com/repos/facebook/jest","labels_url":"https://api.github.com/repos/facebook/jest/issues/6066/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/6066/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/6066/events","html_url":"https://github.com/facebook/jest/issues/6066","id":317580085,"number":6066,"title":"Persist require.cache after globalSetup","user":{"login":"faustbrian","id":22145591,"avatar_url":"https://avatars3.githubusercontent.com/u/22145591?v=4","gravatar_id":"","url":"https://api.github.com/users/faustbrian","html_url":"https://github.com/faustbrian","followers_url":"https://api.github.com/users/faustbrian/followers","following_url":"https://api.github.com/users/faustbrian/following{/other_user}","gists_url":"https://api.github.com/users/faustbrian/gists{/gist_id}","starred_url":"https://api.github.com/users/faustbrian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faustbrian/subscriptions","organizations_url":"https://api.github.com/users/faustbrian/orgs","repos_url":"https://api.github.com/users/faustbrian/repos","events_url":"https://api.github.com/users/faustbrian/events{/privacy}","received_events_url":"https://api.github.com/users/faustbrian/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-25T11:04:48Z","updated_at":"2018-04-25T12:54:55Z","closed_at":"2018-04-25T12:40:55Z","author_association":"NONE","body":"**What is the current behaviour?**\r\n\r\nWhen requiring and bootstrapping a node module **(singleton in my case)** during the `globalSetup` like `require('some-node-module')` it will be gone if I try to get the same instance in a test via `require('some-node-module')`.\r\n\r\nOutside of jest this behaviour works perfectly fine since node.js caches any require call which makes it easy to provide the same instance of a module between multiple modules.\r\n\r\n**What is the expected behaviour?**\r\n\r\nAfter calling `require('some-node-module')` in the `globalSetup` all tests should have access to instance of `require('some-node-module')`.\r\n\r\n**Please provide your exact Jest configuration**\r\n\r\n```js\r\nmodule.exports = {\r\n  testEnvironment: 'node',\r\n  moduleFileExtensions: ['js', 'json'],\r\n  globalSetup: './__tests__/setup.js',\r\n  setupTestFrameworkScriptFile: 'jest-extended'\r\n}\r\n```\r\n\r\n**Run `npx envinfo --preset jest` in your project directory and paste the\r\nresults here**\r\n\r\n```\r\n  System:\r\n    OS: macOS High Sierra 10.13.4\r\n    CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz\r\n  Binaries:\r\n    Node: 9.11.1\r\n    Yarn: 1.6.0\r\n    npm: 5.8.0\r\n  npmPackages:\r\n    jest:\r\n      wanted: ^22.4.3\r\n      installed: 22.4.3\r\n```\r\n\r\n**Notes**\r\n\r\nI found that jest ignores the node.js `require.cache` but is there some way to enable the `require.cache` for tests?"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/384276173","html_url":"https://github.com/facebook/jest/issues/6066#issuecomment-384276173","issue_url":"https://api.github.com/repos/facebook/jest/issues/6066","id":384276173,"user":{"login":"faustbrian","id":22145591,"avatar_url":"https://avatars3.githubusercontent.com/u/22145591?v=4","gravatar_id":"","url":"https://api.github.com/users/faustbrian","html_url":"https://github.com/faustbrian","followers_url":"https://api.github.com/users/faustbrian/followers","following_url":"https://api.github.com/users/faustbrian/following{/other_user}","gists_url":"https://api.github.com/users/faustbrian/gists{/gist_id}","starred_url":"https://api.github.com/users/faustbrian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faustbrian/subscriptions","organizations_url":"https://api.github.com/users/faustbrian/orgs","repos_url":"https://api.github.com/users/faustbrian/repos","events_url":"https://api.github.com/users/faustbrian/events{/privacy}","received_events_url":"https://api.github.com/users/faustbrian/received_events","type":"User","site_admin":false},"created_at":"2018-04-25T12:54:55Z","updated_at":"2018-04-25T12:54:55Z","author_association":"NONE","body":"So there is absolutely no way to achieve this with jest, not even any workarounds?"}}
{"actor":{"display_login":"faustbrian"}}