{"action":"created","issue":{"url":"https://api.github.com/repos/midwayjs/module-hook/issues/5","repository_url":"https://api.github.com/repos/midwayjs/module-hook","labels_url":"https://api.github.com/repos/midwayjs/module-hook/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/midwayjs/module-hook/issues/5/comments","events_url":"https://api.github.com/repos/midwayjs/module-hook/issues/5/events","html_url":"https://github.com/midwayjs/module-hook/issues/5","id":319827902,"number":5,"title":"和测试框架 jest 不兼容","user":{"login":"myfjdthink","id":2044143,"avatar_url":"https://avatars2.githubusercontent.com/u/2044143?v=4","gravatar_id":"","url":"https://api.github.com/users/myfjdthink","html_url":"https://github.com/myfjdthink","followers_url":"https://api.github.com/users/myfjdthink/followers","following_url":"https://api.github.com/users/myfjdthink/following{/other_user}","gists_url":"https://api.github.com/users/myfjdthink/gists{/gist_id}","starred_url":"https://api.github.com/users/myfjdthink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myfjdthink/subscriptions","organizations_url":"https://api.github.com/users/myfjdthink/orgs","repos_url":"https://api.github.com/users/myfjdthink/repos","events_url":"https://api.github.com/users/myfjdthink/events{/privacy}","received_events_url":"https://api.github.com/users/myfjdthink/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"mariodu","id":1409643,"avatar_url":"https://avatars2.githubusercontent.com/u/1409643?v=4","gravatar_id":"","url":"https://api.github.com/users/mariodu","html_url":"https://github.com/mariodu","followers_url":"https://api.github.com/users/mariodu/followers","following_url":"https://api.github.com/users/mariodu/following{/other_user}","gists_url":"https://api.github.com/users/mariodu/gists{/gist_id}","starred_url":"https://api.github.com/users/mariodu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariodu/subscriptions","organizations_url":"https://api.github.com/users/mariodu/orgs","repos_url":"https://api.github.com/users/mariodu/repos","events_url":"https://api.github.com/users/mariodu/events{/privacy}","received_events_url":"https://api.github.com/users/mariodu/received_events","type":"User","site_admin":false},"assignees":[{"login":"mariodu","id":1409643,"avatar_url":"https://avatars2.githubusercontent.com/u/1409643?v=4","gravatar_id":"","url":"https://api.github.com/users/mariodu","html_url":"https://github.com/mariodu","followers_url":"https://api.github.com/users/mariodu/followers","following_url":"https://api.github.com/users/mariodu/following{/other_user}","gists_url":"https://api.github.com/users/mariodu/gists{/gist_id}","starred_url":"https://api.github.com/users/mariodu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariodu/subscriptions","organizations_url":"https://api.github.com/users/mariodu/orgs","repos_url":"https://api.github.com/users/mariodu/repos","events_url":"https://api.github.com/users/mariodu/events{/privacy}","received_events_url":"https://api.github.com/users/mariodu/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-05-03T08:26:01Z","updated_at":"2018-05-03T09:09:47Z","closed_at":null,"author_association":"NONE","body":"准备一个测试 ModuleHook.test.js \r\n```js\r\nconst {hook} = require('module-hook')\r\nconst sinon = require('sinon')\r\nconst assert = require('assert')\r\n\r\ndescribe('test/index.test.ts', () => {\r\n  it('should loadModule work ok', done => {\r\n    const spy = sinon.spy()\r\n    hook('semver', '5.x', (loadModule, replaceSource, version) => {\r\n      const semver = loadModule('semver.js');\r\n      console.log('version', version)\r\n      spy()\r\n      assert(version)\r\n      assert(semver);\r\n    });\r\n    require('semver');\r\n    assert(spy.calledOnce);\r\n    done()\r\n  });\r\n})\r\n```\r\n运行 \r\n`mocha ModuleHook.test.js `\r\n没问题，测试通过\r\n\r\n运行 \r\n`jest ModuleHook.test.js`\r\n测试失败\r\n```\r\n    Received:\r\n      false\r\n\r\n      14 |     });\r\n      15 |     require('semver');\r\n    > 16 |     assert(spy.calledOnce);\r\n      17 |     done()\r\n      18 |   });\r\n      19 | })\r\n```\r\n\r\n@mariodu "},"comment":{"url":"https://api.github.com/repos/midwayjs/module-hook/issues/comments/386234340","html_url":"https://github.com/midwayjs/module-hook/issues/5#issuecomment-386234340","issue_url":"https://api.github.com/repos/midwayjs/module-hook/issues/5","id":386234340,"user":{"login":"mariodu","id":1409643,"avatar_url":"https://avatars2.githubusercontent.com/u/1409643?v=4","gravatar_id":"","url":"https://api.github.com/users/mariodu","html_url":"https://github.com/mariodu","followers_url":"https://api.github.com/users/mariodu/followers","following_url":"https://api.github.com/users/mariodu/following{/other_user}","gists_url":"https://api.github.com/users/mariodu/gists{/gist_id}","starred_url":"https://api.github.com/users/mariodu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariodu/subscriptions","organizations_url":"https://api.github.com/users/mariodu/orgs","repos_url":"https://api.github.com/users/mariodu/repos","events_url":"https://api.github.com/users/mariodu/events{/privacy}","received_events_url":"https://api.github.com/users/mariodu/received_events","type":"User","site_admin":false},"created_at":"2018-05-03T09:09:47Z","updated_at":"2018-05-03T09:09:47Z","author_association":"MEMBER","body":"你是要自己写测试用例？"}}
{"actor":{"display_login":"mariodu"}}