{"action":"created","issue":{"url":"https://api.github.com/repos/mochajs/mocha/issues/3519","repository_url":"https://api.github.com/repos/mochajs/mocha","labels_url":"https://api.github.com/repos/mochajs/mocha/issues/3519/labels{/name}","comments_url":"https://api.github.com/repos/mochajs/mocha/issues/3519/comments","events_url":"https://api.github.com/repos/mochajs/mocha/issues/3519/events","html_url":"https://github.com/mochajs/mocha/issues/3519","id":370840946,"node_id":"MDU6SXNzdWUzNzA4NDA5NDY=","number":3519,"title":"Mocha ignores timeout on Promise test functions","user":{"login":"jasonswearingen","id":814134,"node_id":"MDQ6VXNlcjgxNDEzNA==","avatar_url":"https://avatars0.githubusercontent.com/u/814134?v=4","gravatar_id":"","url":"https://api.github.com/users/jasonswearingen","html_url":"https://github.com/jasonswearingen","followers_url":"https://api.github.com/users/jasonswearingen/followers","following_url":"https://api.github.com/users/jasonswearingen/following{/other_user}","gists_url":"https://api.github.com/users/jasonswearingen/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonswearingen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonswearingen/subscriptions","organizations_url":"https://api.github.com/users/jasonswearingen/orgs","repos_url":"https://api.github.com/users/jasonswearingen/repos","events_url":"https://api.github.com/users/jasonswearingen/events{/privacy}","received_events_url":"https://api.github.com/users/jasonswearingen/received_events","type":"User","site_admin":false},"labels":[{"id":124825182,"node_id":"MDU6TGFiZWwxMjQ4MjUxODI=","url":"https://api.github.com/repos/mochajs/mocha/labels/needs-feedback","name":"needs-feedback","color":"FCEB43","default":false},{"id":210273,"node_id":"MDU6TGFiZWwyMTAyNzM=","url":"https://api.github.com/repos/mochajs/mocha/labels/unconfirmed-bug","name":"unconfirmed-bug","color":"995A44","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2018-10-16T23:35:57Z","updated_at":"2018-11-01T17:53:01Z","closed_at":"2018-11-01T17:53:01Z","author_association":"NONE","body":"### Prerequisites\r\n- [ X] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20)\r\n- [ X] Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.\r\n- [ x] 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself\r\n- [x ] Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: `node node_modules/.bin/mocha --version`(Local) and `mocha --version`(Global). We recommend avoiding the use of globally installed Mocha.\r\n\r\n### Description\r\nMocha does not respect specifying a ```timeout``` for tests that return promises.\r\n\r\nI want to set a max timeout by invoking ```mochaTest.timeout(1000)``` but it is ignored.\r\n\r\n### Steps to Reproduce\r\n```javascript\r\ndescribe( \"reproduce promise timeout ignores\", function () {\r\n\r\n\tit( \"should timeout\", function () {\r\n\t\tthis.timeout( 1000 );\r\n\t\treturn new Promise( function ( resolve, reject ) {\r\n\t\t\tsetTimeout( function () {\r\n\t\t\t\tresolve();\r\n\t\t\t}, 3000 );\r\n\t\t} );\r\n\t} );\r\n\r\n\tconst test = it( \"should timeout2\", function () {\r\n\t\treturn new Promise( function ( resolve, reject ) {\r\n\t\t\tsetTimeout( function () {\r\n\t\t\t\tresolve();\r\n\t\t\t}, 3000 );\r\n\t\t} );\r\n\t} );\r\n\ttest.timeout( 1000 );\r\n\r\n} );\r\n```\r\n\r\n**Expected behavior:** [What you expect to happen]\r\nexpect the tests to fail after 1000ms due to timeout.  I can understand why the first ```\"should timeout\"``` test might not work with my desired timeout (setting the timeout inside the async method) but the second ```\"should timeout2\"``` should work as desired.\r\n\r\n**Actual behavior:** [What actually happens]\r\ntests pass after aprox 3000ms\r\n```bash\r\n  reproduce promise timeout ignores\r\n    √ should timeout (3006ms)\r\n    √ should timeout2 (3001ms)\r\n\r\n  2 passing (6s)\r\n```\r\n\r\n**Reproduces how often:** [What percentage of the time does it reproduce?]\r\nall the time\r\n\r\n### Versions\r\n``` bash\r\nmocha --version\r\n5.2.0\r\n\r\nnode_modules/.bin/mocha --version\r\n5.2.0\r\n\r\nnode --version\r\nv8.11.4\r\n\r\nos:\r\nwin10 x64 v1803 b17134.345\r\n\r\nshell:\r\ncmd and/or powershell\r\n\r\nbrowser ver:\r\nN/A\r\n\r\nmocha modules:\r\nN/A\r\n\r\ntranspiled via:\r\nN/A\r\n\r\n```\r\n\r\n### Additional Information\r\n\r\nmy full commandline for running the tests:\r\n```\r\n'C:\\Users\\jason\\AppData\\Roaming\\npm\\mocha.cmd' '--watch' '--colors' '--trace-warnings' '--inspect-brk=45370' './dist/**/mocha.test.js'\r\n```"},"comment":{"url":"https://api.github.com/repos/mochajs/mocha/issues/comments/435127098","html_url":"https://github.com/mochajs/mocha/issues/3519#issuecomment-435127098","issue_url":"https://api.github.com/repos/mochajs/mocha/issues/3519","id":435127098,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTEyNzA5OA==","user":{"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},"created_at":"2018-11-01T17:53:01Z","updated_at":"2018-11-01T17:53:01Z","author_association":"MEMBER","body":"> `mocha --timeout --inspect` is giving the correct result and the tests are failing.\r\n> \r\n> This is strange since --timeout is expecting a parameter ms.\r\n> `mocha --timeout` as expected results in: `error: option -t, --timeout <ms> argument missing`\r\n> \r\n> `mocha --timeout 0` and `mocha --inspect` show exactly the same results, tests are passing.\r\n> \r\n> My guess is the value of timeout is lost somewhere when used with --inspect.\r\n\r\nThey [`--timeout`/`--no-timeouts`] cancelled each other out."}}
{"actor":{"display_login":"plroebuck"}}