Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest + Supertest + Restify not working #982

Closed
ravilution opened this issue May 9, 2016 · 2 comments
Closed

Jest + Supertest + Restify not working #982

ravilution opened this issue May 9, 2016 · 2 comments

Comments

@ravilution
Copy link

@cpojer Reopening the accidentally closed #977

node 5.4.1
jest-cli ^12.0.2
restify ^4.0.4
supertest ^1.2.0

I want to use Jest to do backend nodejs REST API testing also. I do not want to install another test tool like mocha etc.

'use strict';
var request = require('supertest')(require('../appServer'));
describe('Test', function () {
    it('works', function () {
        request
            .get('/api')
            .expect(200)
            .end(function (err, res) {
                expect(err).toEqual(null);
            });
    });
});

In above code appServer returns a restify server instance. I am using supertest because I want to do code coverage as well. But I get below error.

Error: Cannot find module '_http_common' from 'stream.js'
    at Runtime._resolveNodeModule (/Users/me/Documents/workspace/node_modules/jest-cli/src/Runtime/Runtime.js:451:11)
    at Object.<anonymous> (/Users/me/Documents/workspace/node_modules/spdy/lib/spdy/stream.js:13:20)
    at Object.<anonymous> (/Users/me/Documents/workspace/node_modules/spdy/lib/spdy.js:19:15)

I have automock turned off. I also tried you unmock code. I also tried jest.disableAutomock();. Nothing works. Below is my jest config in package.json

  "jest": {
    "automock": false,
    "bail": true,
    "collectCoverage": true,
    "moduleFileExtensions": [
      "js"
    ],
    "scriptPreprocessor": "./node_modules/babel-jest",
    "testFileExtensions": [
      "js"
    ],
    "testPathDirs": [
      "./client/src",
      "./server"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/client/build/",
      "/docs/",
      "/logs/",
      "/coverage/"
    ]
  }
@cpojer
Copy link
Member

cpojer commented May 9, 2016

Reopened #977.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants