{"action":"created","comment":{"url":"https://api.github.com/repos/mochajs/mocha/pulls/comments/244381448","pull_request_review_id":188346616,"id":244381448,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDM4MTQ0OA==","diff_hunk":"@@ -272,7 +272,11 @@ Runner.prototype.failHook = function(hook, err) {\n     hook.title =\n       hook.originalTitle + ' for \"' + hook.ctx.currentTest.title + '\"';\n   } else {\n-    var parent = hook.parent ? hook.parent.title : 'root';\n+    var parent = hook.parent.title\n+      ? hook.parent.title\n+      : hook.parent.root && !hook.parent.parent\n+        ? 'root'\n+        : '';","path":"lib/runner.js","position":9,"original_position":9,"commit_id":"c42a2a98f19012975d41101c485dbb4ba27bfa1a","original_commit_id":"9feb3bb8f5538ec55b0d4184dc352fa8a5062f9b","user":{"login":"juergba","id":44573692,"node_id":"MDQ6VXNlcjQ0NTczNjky","avatar_url":"https://avatars1.githubusercontent.com/u/44573692?v=4","gravatar_id":"","url":"https://api.github.com/users/juergba","html_url":"https://github.com/juergba","followers_url":"https://api.github.com/users/juergba/followers","following_url":"https://api.github.com/users/juergba/following{/other_user}","gists_url":"https://api.github.com/users/juergba/gists{/gist_id}","starred_url":"https://api.github.com/users/juergba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juergba/subscriptions","organizations_url":"https://api.github.com/users/juergba/orgs","repos_url":"https://api.github.com/users/juergba/repos","events_url":"https://api.github.com/users/juergba/events{/privacy}","received_events_url":"https://api.github.com/users/juergba/received_events","type":"User","site_admin":false},"body":"see PR #3632","created_at":"2018-12-28T18:35:55Z","updated_at":"2018-12-28T18:35:56Z","html_url":"https://github.com/mochajs/mocha/pull/3573#discussion_r244381448","pull_request_url":"https://api.github.com/repos/mochajs/mocha/pulls/3573","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/comments/244381448"},"html":{"href":"https://github.com/mochajs/mocha/pull/3573#discussion_r244381448"},"pull_request":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3573"}},"in_reply_to_id":241348990},"pull_request":{"url":"https://api.github.com/repos/mochajs/mocha/pulls/3573","id":231310884,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxMzEwODg0","html_url":"https://github.com/mochajs/mocha/pull/3573","diff_url":"https://github.com/mochajs/mocha/pull/3573.diff","patch_url":"https://github.com/mochajs/mocha/pull/3573.patch","issue_url":"https://api.github.com/repos/mochajs/mocha/issues/3573","number":3573,"state":"open","locked":false,"title":"Fix Hook Test Names","user":{"login":"juergba","id":44573692,"node_id":"MDQ6VXNlcjQ0NTczNjky","avatar_url":"https://avatars1.githubusercontent.com/u/44573692?v=4","gravatar_id":"","url":"https://api.github.com/users/juergba","html_url":"https://github.com/juergba","followers_url":"https://api.github.com/users/juergba/followers","following_url":"https://api.github.com/users/juergba/following{/other_user}","gists_url":"https://api.github.com/users/juergba/gists{/gist_id}","starred_url":"https://api.github.com/users/juergba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juergba/subscriptions","organizations_url":"https://api.github.com/users/juergba/orgs","repos_url":"https://api.github.com/users/juergba/repos","events_url":"https://api.github.com/users/juergba/events{/privacy}","received_events_url":"https://api.github.com/users/juergba/received_events","type":"User","site_admin":false},"body":"### Description of bug\r\nMocha shows an incorrect test-title if a nested `before` hook fails. For `after` hooks the second part of the message is completely missing.\r\n```\r\ndescribe('Top-level describe', () => {\r\n  it('Top-level it', () => { });       <<< the failing before-hook is pointing to this test\r\n  describe('Nested describe', () => {\r\n    before(() => {\r\n      throw new Error();\r\n    });\r\n    it('Nested it', () => { });        <<< but it should point to this test\r\n  });\r\n});\r\n```\r\n```\r\nTop-level describe\r\n    ✓ Top-level it\r\n    Nested describe\r\n      1) \"before all\" hook for \"Top-level it\"       <<<incorrect\r\n```\r\nRoot problem: see [#1638](https://github.com/mochajs/mocha/issues/1638). `hook.ctx.currentTest` is set incorrectly in the hook before emitting the hook event:\r\n- `before` hook: currentTest is undefined or points to the outer test already past successfully.\r\nThe runner hasn't reached the next test to come yet, so it's too early to derive currentTest from the runner. Instead the first test of hook's parent is used.\r\n- `after` hook: currentTest is undefined.\r\nThe runner has already completed the latest test and runner.currentTest is deleted. Instead the last test of hook's parent is used.\r\n\r\n### Description of the Change\r\n#### 1. Setting currentTest correctly\r\n- `before` hook: hook.ctx.currentTest is set to the first test of the parent suite\r\n- `after hook`: hook.ctx.currentTest is set to the last test of the parent suite\r\n- for nested suites just the current suite is searched for tests to come. When no tests can be found, currentTest remains undefined.\r\n\r\n#### 2. Creating title in hook failure message\r\nA correct `hook.ctx.currentTest` renders a correct title. \r\nWhen no currentTest can be found, the title of the parent suite is used for the hook failure message.\r\n\r\n### Alternate Designs\r\nPR [#3333](https://github.com/mochajs/mocha/pull/3333)\r\n\r\n### Benefits\r\n\r\nThis is a rather old bug back to 2015.\r\n\r\n### Applicable issues\r\n[#1638](https://github.com/mochajs/mocha/issues/1638)\r\n[#3291](https://github.com/mochajs/mocha/issues/3291)\r\n[#2134](https://github.com/mochajs/mocha/issues/2134)\r\n","created_at":"2018-11-15T19:39:05Z","updated_at":"2018-12-28T18:35:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"624ce91872c3b72ff5a184044067a1c1709e08c5","assignee":null,"assignees":[],"requested_reviewers":[{"login":"outsideris","id":390146,"node_id":"MDQ6VXNlcjM5MDE0Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/390146?v=4","gravatar_id":"","url":"https://api.github.com/users/outsideris","html_url":"https://github.com/outsideris","followers_url":"https://api.github.com/users/outsideris/followers","following_url":"https://api.github.com/users/outsideris/following{/other_user}","gists_url":"https://api.github.com/users/outsideris/gists{/gist_id}","starred_url":"https://api.github.com/users/outsideris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/outsideris/subscriptions","organizations_url":"https://api.github.com/users/outsideris/orgs","repos_url":"https://api.github.com/users/outsideris/repos","events_url":"https://api.github.com/users/outsideris/events{/privacy}","received_events_url":"https://api.github.com/users/outsideris/received_events","type":"User","site_admin":false},{"login":"Bamieh","id":6191849,"node_id":"MDQ6VXNlcjYxOTE4NDk=","avatar_url":"https://avatars3.githubusercontent.com/u/6191849?v=4","gravatar_id":"","url":"https://api.github.com/users/Bamieh","html_url":"https://github.com/Bamieh","followers_url":"https://api.github.com/users/Bamieh/followers","following_url":"https://api.github.com/users/Bamieh/following{/other_user}","gists_url":"https://api.github.com/users/Bamieh/gists{/gist_id}","starred_url":"https://api.github.com/users/Bamieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bamieh/subscriptions","organizations_url":"https://api.github.com/users/Bamieh/orgs","repos_url":"https://api.github.com/users/Bamieh/repos","events_url":"https://api.github.com/users/Bamieh/events{/privacy}","received_events_url":"https://api.github.com/users/Bamieh/received_events","type":"User","site_admin":false},{"login":"plroebuck","id":16603429,"node_id":"MDQ6VXNlcjE2NjAzNDI5","avatar_url":"https://avatars1.githubusercontent.com/u/16603429?v=4","gravatar_id":"","url":"https://api.github.com/users/plroebuck","html_url":"https://github.com/plroebuck","followers_url":"https://api.github.com/users/plroebuck/followers","following_url":"https://api.github.com/users/plroebuck/following{/other_user}","gists_url":"https://api.github.com/users/plroebuck/gists{/gist_id}","starred_url":"https://api.github.com/users/plroebuck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plroebuck/subscriptions","organizations_url":"https://api.github.com/users/plroebuck/orgs","repos_url":"https://api.github.com/users/plroebuck/repos","events_url":"https://api.github.com/users/plroebuck/events{/privacy}","received_events_url":"https://api.github.com/users/plroebuck/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":184344,"node_id":"MDU6TGFiZWwxODQzNDQ=","url":"https://api.github.com/repos/mochajs/mocha/labels/confirmed-bug","name":"confirmed-bug","color":"A6340C","default":false},{"id":533082117,"node_id":"MDU6TGFiZWw1MzMwODIxMTc=","url":"https://api.github.com/repos/mochajs/mocha/labels/semver-patch","name":"semver-patch","color":"0e8a16","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mochajs/mocha/pulls/3573/commits","review_comments_url":"https://api.github.com/repos/mochajs/mocha/pulls/3573/comments","review_comment_url":"https://api.github.com/repos/mochajs/mocha/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mochajs/mocha/issues/3573/comments","statuses_url":"https://api.github.com/repos/mochajs/mocha/statuses/c42a2a98f19012975d41101c485dbb4ba27bfa1a","head":{"label":"juergba:issues/3291","ref":"issues/3291","sha":"c42a2a98f19012975d41101c485dbb4ba27bfa1a","user":{"login":"juergba","id":44573692,"node_id":"MDQ6VXNlcjQ0NTczNjky","avatar_url":"https://avatars1.githubusercontent.com/u/44573692?v=4","gravatar_id":"","url":"https://api.github.com/users/juergba","html_url":"https://github.com/juergba","followers_url":"https://api.github.com/users/juergba/followers","following_url":"https://api.github.com/users/juergba/following{/other_user}","gists_url":"https://api.github.com/users/juergba/gists{/gist_id}","starred_url":"https://api.github.com/users/juergba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juergba/subscriptions","organizations_url":"https://api.github.com/users/juergba/orgs","repos_url":"https://api.github.com/users/juergba/repos","events_url":"https://api.github.com/users/juergba/events{/privacy}","received_events_url":"https://api.github.com/users/juergba/received_events","type":"User","site_admin":false},"repo":{"id":157212018,"node_id":"MDEwOlJlcG9zaXRvcnkxNTcyMTIwMTg=","name":"mocha","full_name":"juergba/mocha","private":false,"owner":{"login":"juergba","id":44573692,"node_id":"MDQ6VXNlcjQ0NTczNjky","avatar_url":"https://avatars1.githubusercontent.com/u/44573692?v=4","gravatar_id":"","url":"https://api.github.com/users/juergba","html_url":"https://github.com/juergba","followers_url":"https://api.github.com/users/juergba/followers","following_url":"https://api.github.com/users/juergba/following{/other_user}","gists_url":"https://api.github.com/users/juergba/gists{/gist_id}","starred_url":"https://api.github.com/users/juergba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juergba/subscriptions","organizations_url":"https://api.github.com/users/juergba/orgs","repos_url":"https://api.github.com/users/juergba/repos","events_url":"https://api.github.com/users/juergba/events{/privacy}","received_events_url":"https://api.github.com/users/juergba/received_events","type":"User","site_admin":false},"html_url":"https://github.com/juergba/mocha","description":"☕️ simple, flexible, fun javascript test framework for node.js & the browser","fork":true,"url":"https://api.github.com/repos/juergba/mocha","forks_url":"https://api.github.com/repos/juergba/mocha/forks","keys_url":"https://api.github.com/repos/juergba/mocha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juergba/mocha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juergba/mocha/teams","hooks_url":"https://api.github.com/repos/juergba/mocha/hooks","issue_events_url":"https://api.github.com/repos/juergba/mocha/issues/events{/number}","events_url":"https://api.github.com/repos/juergba/mocha/events","assignees_url":"https://api.github.com/repos/juergba/mocha/assignees{/user}","branches_url":"https://api.github.com/repos/juergba/mocha/branches{/branch}","tags_url":"https://api.github.com/repos/juergba/mocha/tags","blobs_url":"https://api.github.com/repos/juergba/mocha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juergba/mocha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juergba/mocha/git/refs{/sha}","trees_url":"https://api.github.com/repos/juergba/mocha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juergba/mocha/statuses/{sha}","languages_url":"https://api.github.com/repos/juergba/mocha/languages","stargazers_url":"https://api.github.com/repos/juergba/mocha/stargazers","contributors_url":"https://api.github.com/repos/juergba/mocha/contributors","subscribers_url":"https://api.github.com/repos/juergba/mocha/subscribers","subscription_url":"https://api.github.com/repos/juergba/mocha/subscription","commits_url":"https://api.github.com/repos/juergba/mocha/commits{/sha}","git_commits_url":"https://api.github.com/repos/juergba/mocha/git/commits{/sha}","comments_url":"https://api.github.com/repos/juergba/mocha/comments{/number}","issue_comment_url":"https://api.github.com/repos/juergba/mocha/issues/comments{/number}","contents_url":"https://api.github.com/repos/juergba/mocha/contents/{+path}","compare_url":"https://api.github.com/repos/juergba/mocha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juergba/mocha/merges","archive_url":"https://api.github.com/repos/juergba/mocha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juergba/mocha/downloads","issues_url":"https://api.github.com/repos/juergba/mocha/issues{/number}","pulls_url":"https://api.github.com/repos/juergba/mocha/pulls{/number}","milestones_url":"https://api.github.com/repos/juergba/mocha/milestones{/number}","notifications_url":"https://api.github.com/repos/juergba/mocha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juergba/mocha/labels{/name}","releases_url":"https://api.github.com/repos/juergba/mocha/releases{/id}","deployments_url":"https://api.github.com/repos/juergba/mocha/deployments","created_at":"2018-11-12T12:42:37Z","updated_at":"2018-12-20T13:50:24Z","pushed_at":"2018-12-28T13:45:13Z","git_url":"git://github.com/juergba/mocha.git","ssh_url":"git@github.com:juergba/mocha.git","clone_url":"https://github.com/juergba/mocha.git","svn_url":"https://github.com/juergba/mocha","homepage":"https://mochajs.org","size":10002,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mochajs:master","ref":"master","sha":"6df0e84dc873167456c2b4a384f464190ad1a540","user":{"login":"mochajs","id":8770005,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg3NzAwMDU=","avatar_url":"https://avatars2.githubusercontent.com/u/8770005?v=4","gravatar_id":"","url":"https://api.github.com/users/mochajs","html_url":"https://github.com/mochajs","followers_url":"https://api.github.com/users/mochajs/followers","following_url":"https://api.github.com/users/mochajs/following{/other_user}","gists_url":"https://api.github.com/users/mochajs/gists{/gist_id}","starred_url":"https://api.github.com/users/mochajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mochajs/subscriptions","organizations_url":"https://api.github.com/users/mochajs/orgs","repos_url":"https://api.github.com/users/mochajs/repos","events_url":"https://api.github.com/users/mochajs/events{/privacy}","received_events_url":"https://api.github.com/users/mochajs/received_events","type":"Organization","site_admin":false},"repo":{"id":1451352,"node_id":"MDEwOlJlcG9zaXRvcnkxNDUxMzUy","name":"mocha","full_name":"mochajs/mocha","private":false,"owner":{"login":"mochajs","id":8770005,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg3NzAwMDU=","avatar_url":"https://avatars2.githubusercontent.com/u/8770005?v=4","gravatar_id":"","url":"https://api.github.com/users/mochajs","html_url":"https://github.com/mochajs","followers_url":"https://api.github.com/users/mochajs/followers","following_url":"https://api.github.com/users/mochajs/following{/other_user}","gists_url":"https://api.github.com/users/mochajs/gists{/gist_id}","starred_url":"https://api.github.com/users/mochajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mochajs/subscriptions","organizations_url":"https://api.github.com/users/mochajs/orgs","repos_url":"https://api.github.com/users/mochajs/repos","events_url":"https://api.github.com/users/mochajs/events{/privacy}","received_events_url":"https://api.github.com/users/mochajs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/mochajs/mocha","description":"☕️ simple, flexible, fun javascript test framework for node.js & the browser","fork":false,"url":"https://api.github.com/repos/mochajs/mocha","forks_url":"https://api.github.com/repos/mochajs/mocha/forks","keys_url":"https://api.github.com/repos/mochajs/mocha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mochajs/mocha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mochajs/mocha/teams","hooks_url":"https://api.github.com/repos/mochajs/mocha/hooks","issue_events_url":"https://api.github.com/repos/mochajs/mocha/issues/events{/number}","events_url":"https://api.github.com/repos/mochajs/mocha/events","assignees_url":"https://api.github.com/repos/mochajs/mocha/assignees{/user}","branches_url":"https://api.github.com/repos/mochajs/mocha/branches{/branch}","tags_url":"https://api.github.com/repos/mochajs/mocha/tags","blobs_url":"https://api.github.com/repos/mochajs/mocha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mochajs/mocha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mochajs/mocha/git/refs{/sha}","trees_url":"https://api.github.com/repos/mochajs/mocha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mochajs/mocha/statuses/{sha}","languages_url":"https://api.github.com/repos/mochajs/mocha/languages","stargazers_url":"https://api.github.com/repos/mochajs/mocha/stargazers","contributors_url":"https://api.github.com/repos/mochajs/mocha/contributors","subscribers_url":"https://api.github.com/repos/mochajs/mocha/subscribers","subscription_url":"https://api.github.com/repos/mochajs/mocha/subscription","commits_url":"https://api.github.com/repos/mochajs/mocha/commits{/sha}","git_commits_url":"https://api.github.com/repos/mochajs/mocha/git/commits{/sha}","comments_url":"https://api.github.com/repos/mochajs/mocha/comments{/number}","issue_comment_url":"https://api.github.com/repos/mochajs/mocha/issues/comments{/number}","contents_url":"https://api.github.com/repos/mochajs/mocha/contents/{+path}","compare_url":"https://api.github.com/repos/mochajs/mocha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mochajs/mocha/merges","archive_url":"https://api.github.com/repos/mochajs/mocha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mochajs/mocha/downloads","issues_url":"https://api.github.com/repos/mochajs/mocha/issues{/number}","pulls_url":"https://api.github.com/repos/mochajs/mocha/pulls{/number}","milestones_url":"https://api.github.com/repos/mochajs/mocha/milestones{/number}","notifications_url":"https://api.github.com/repos/mochajs/mocha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mochajs/mocha/labels{/name}","releases_url":"https://api.github.com/repos/mochajs/mocha/releases{/id}","deployments_url":"https://api.github.com/repos/mochajs/mocha/deployments","created_at":"2011-03-07T18:44:25Z","updated_at":"2018-12-28T18:35:50Z","pushed_at":"2018-12-28T13:45:17Z","git_url":"git://github.com/mochajs/mocha.git","ssh_url":"git@github.com:mochajs/mocha.git","clone_url":"https://github.com/mochajs/mocha.git","svn_url":"https://github.com/mochajs/mocha","homepage":"https://mochajs.org","size":10390,"stargazers_count":16874,"watchers_count":16874,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2306,"mirror_url":null,"archived":false,"open_issues_count":278,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":2306,"open_issues":278,"watchers":16874,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3573"},"html":{"href":"https://github.com/mochajs/mocha/pull/3573"},"issue":{"href":"https://api.github.com/repos/mochajs/mocha/issues/3573"},"comments":{"href":"https://api.github.com/repos/mochajs/mocha/issues/3573/comments"},"review_comments":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3573/comments"},"review_comment":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3573/commits"},"statuses":{"href":"https://api.github.com/repos/mochajs/mocha/statuses/c42a2a98f19012975d41101c485dbb4ba27bfa1a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"juergba"}}