{"action":"opened","issue":{"url":"https://api.github.com/repos/jhnns/rewire/issues/150","repository_url":"https://api.github.com/repos/jhnns/rewire","labels_url":"https://api.github.com/repos/jhnns/rewire/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/jhnns/rewire/issues/150/comments","events_url":"https://api.github.com/repos/jhnns/rewire/issues/150/events","html_url":"https://github.com/jhnns/rewire/issues/150","id":365387130,"node_id":"MDU6SXNzdWUzNjUzODcxMzA=","number":150,"title":"Can I mock global object called outside any block?","user":{"login":"hbielenia","id":13271065,"node_id":"MDQ6VXNlcjEzMjcxMDY1","avatar_url":"https://avatars1.githubusercontent.com/u/13271065?v=4","gravatar_id":"","url":"https://api.github.com/users/hbielenia","html_url":"https://github.com/hbielenia","followers_url":"https://api.github.com/users/hbielenia/followers","following_url":"https://api.github.com/users/hbielenia/following{/other_user}","gists_url":"https://api.github.com/users/hbielenia/gists{/gist_id}","starred_url":"https://api.github.com/users/hbielenia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbielenia/subscriptions","organizations_url":"https://api.github.com/users/hbielenia/orgs","repos_url":"https://api.github.com/users/hbielenia/repos","events_url":"https://api.github.com/users/hbielenia/events{/privacy}","received_events_url":"https://api.github.com/users/hbielenia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-01T09:54:43Z","updated_at":"2018-10-01T09:54:43Z","closed_at":null,"author_association":"NONE","body":"Hi and sorry for asking here - I really done my research, but looks like I'm out of options.\r\n\r\nI would like to use rewire to test a piece of client-side code. The code starts with this:\r\n\r\n```\r\nlet dateInput = document.getElementById('date');\r\nlet dateReset = document.getElementById('reset');\r\n```\r\nThis immediately gives error when rewire attempts to load the module:\r\n```\r\nTypeError: Cannot read property 'getElementById' of undefined\r\n\r\n    > 1 | let dateInput = document.getElementById('date');\r\n        |                                                                                         ^\r\n      2 | let dateReset = document.getElementById('reset');\r\n      3 | \r\n      4 | // Common code for extracting active tab information.\r\n\r\n      at src/popup.js:1:7655\r\n      at Object.<anonymous> (src/popup.js:145:4)\r\n      at Object.load (node_modules/rewire/lib/moduleEnv.js:55:18)\r\n      at internalRewire (node_modules/rewire/lib/rewire.js:49:15)\r\n      at rewire (node_modules/rewire/lib/index.js:11:12)\r\n      at Object.rewire (test/popup.test.js:5:16)\r\n```\r\nI have prepared a mock for `document` global, but it looks like I cannot set it because the error occurs immediately on the line `const popup = rewire('../src/popup.js');`. What is the proper way to do it with rewire?"}}
{"actor":{"display_login":"hbielenia"}}