{"action":"created","issue":{"url":"https://api.github.com/repos/tapjs/node-tap/issues/293","repository_url":"https://api.github.com/repos/tapjs/node-tap","labels_url":"https://api.github.com/repos/tapjs/node-tap/issues/293/labels{/name}","comments_url":"https://api.github.com/repos/tapjs/node-tap/issues/293/comments","events_url":"https://api.github.com/repos/tapjs/node-tap/issues/293/events","html_url":"https://github.com/tapjs/node-tap/issues/293","id":172713017,"number":293,"title":"Reports 1 failing even all tests passed","user":{"login":"playground","id":243495,"avatar_url":"https://avatars.githubusercontent.com/u/243495?v=3","gravatar_id":"","url":"https://api.github.com/users/playground","html_url":"https://github.com/playground","followers_url":"https://api.github.com/users/playground/followers","following_url":"https://api.github.com/users/playground/following{/other_user}","gists_url":"https://api.github.com/users/playground/gists{/gist_id}","starred_url":"https://api.github.com/users/playground/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/playground/subscriptions","organizations_url":"https://api.github.com/users/playground/orgs","repos_url":"https://api.github.com/users/playground/repos","events_url":"https://api.github.com/users/playground/events{/privacy}","received_events_url":"https://api.github.com/users/playground/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-23T14:24:04Z","updated_at":"2016-08-23T15:46:14Z","closed_at":"2016-08-23T15:46:14Z","body":"Not sure why it's reporting fail.  Here is my test repo https://github.com/playground/sample\r\n\r\nHere is my test server.js\r\n\r\n```javascript\r\n// server.js\r\nvar express = require('express');\r\nvar app = express();\r\nvar users = ['John', 'Joe', 'Moe'];\r\n\r\napp.get('/api/users', function (req, res) {\r\n  res.json(users);\r\n});\r\n\r\nvar port = process.env.PORT || 3000;\r\napp.listen(port, function () {\r\n  console.log('Server running on port %d', port);\r\n});\r\nmodule.exports = app;\r\n```\r\n\r\n```js\r\n// user.test.js\r\n\r\nvar request = require('request');\r\n\r\nvar app = require('../server');\r\n\r\nvar test = require('tap').test;\r\n\r\ntest('First test!', function (assert) {\r\n  //assert.plan(1);\r\n\r\n  request.get('http://localhost:3000/api/users', function(err, res) {\r\n    let json = JSON.parse(res.body);\r\n    assert.equal(json[0], 'John', 'name should be John');\r\n    //assert.equal(json[1], 'Joe', 'name should be John');\r\n    assert.endAll();\r\n  });\r\n});\r\n\r\ntest('Second test!', function (assert) {\r\n  //assert.plan(1);\r\n\r\n  request.get('http://localhost:3000/api/users', function(err, res) {\r\n    let json = JSON.parse(res.body);\r\n    assert.equal(json[0], 'John', 'name should be John');\r\n    //assert.equal(json[1], 'Joe', 'name should be Joe');\r\n    assert.endAll();\r\n  });\r\n});\r\n```\r\n\r\n```\r\ntap --cov -R=spec test/*.test.js --timeout=5\r\n\r\n\r\ntest/user.test.js\r\nServer running on port 3000\r\n  First test!\r\n    ✓ name should be John\r\n\r\n  Second test!\r\n    ✓ name should be John\r\n\r\n  1) timeout!\r\n\r\n  2 passing (5s)\r\n  1 failing\r\n\r\n  1) test/user.test.js timeout!:\r\n     timeout!\r\n  \r\n\r\n-----------|----------|----------|----------|----------|----------------|\r\nFile       |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |\r\n-----------|----------|----------|----------|----------|----------------|\r\nAll files  |      100 |      100 |      100 |      100 |                |\r\n server.js |      100 |      100 |      100 |      100 |                |\r\n-----------|----------|----------|----------|----------|----------------|\r\nnpm ERR! Test failed.  See above for more details.\r\n```"},"comment":{"url":"https://api.github.com/repos/tapjs/node-tap/issues/comments/241778410","html_url":"https://github.com/tapjs/node-tap/issues/293#issuecomment-241778410","issue_url":"https://api.github.com/repos/tapjs/node-tap/issues/293","id":241778410,"user":{"login":"isaacs","id":9287,"avatar_url":"https://avatars.githubusercontent.com/u/9287?v=3","gravatar_id":"","url":"https://api.github.com/users/isaacs","html_url":"https://github.com/isaacs","followers_url":"https://api.github.com/users/isaacs/followers","following_url":"https://api.github.com/users/isaacs/following{/other_user}","gists_url":"https://api.github.com/users/isaacs/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacs/subscriptions","organizations_url":"https://api.github.com/users/isaacs/orgs","repos_url":"https://api.github.com/users/isaacs/repos","events_url":"https://api.github.com/users/isaacs/events{/privacy}","received_events_url":"https://api.github.com/users/isaacs/received_events","type":"User","site_admin":false},"created_at":"2016-08-23T15:46:14Z","updated_at":"2016-08-23T15:46:14Z","body":"The problem is that it's timing out because your server never closes.\r\n\r\nYou can add a final `t.test('shut down server', function (t) { server.close() })` or something, or (if you prefer not to have to put it at the bottom of the file) you can do `t.tearDown(function () { server.close() })`.\r\n\r\nIf you want to spin the server up in one test file, run a bunch of tests against the server (without starting and stopping it in each test file, which can be slow), you can use https://github.com/tapjs/t-up.  Of course, this means that you have to order your tests, but you can have a `test/00-setup.js` that starts the server, and then a `test/zz-teardown.js` that kills it.  Check out the examples in the t-up docs for more guidance."}}
{"actor":{"display_login":"isaacs"}}