I need to test an API served via HTTPS with mocha and super test (the certificate are not expired)  This is a gist of the server :   ... var app = express(); var _options = {     key: fs.readFileSync('my-key.pem');,     cert: fs.readFileSync(...
When using supertest for testing async HTTP requests in JavaScript, what's the difference between these two snippets? Is one of them correct and the other one wrong?  request('http://localhost:8080/').get('/api/people')   .expect(...
I am currently new to Sinon, Mocha, Supertest and in the process to writes tests. In my current scenario, i have authentication library which verifies my "OTP" and after verifying it proceeds to do operation within the callback function.   I...
I'm testing my API endpoints with supertest, and it works great, but i can't figure out how to test if a file download is successful.  In my routes file i have defined the endpoint to be:  app.get('/api/attachment/:id/file', attachmen...
Is it possible to test an Express JS REST API using supertest but replacing the actual database connection with a mock database object? I have unit tests covering the database models and other parts of the application as well as functional tests of t...
I'm using the supertest module to test my Rest API. my API sends JSON all the time. so I'm doing .expect('Content-Type', /json/) for all and each test! I'm repeating again and again!      this is some of my code  it('should li...
I have an image upload endpoint in my API that accepts application/octet-stream requests and handles these streams. I'd like to write test coverage for this endpoint but cannot figure out how to use supertest to stream an image.  Here's my co...
I'm trying to write a test for my server side form validation but I keep getting a Forbidden error.  It seems that this needs to be a 2 step process. Step 1, acquire the CSRF value from the form. Step 2, use the CSRF value to post to the form han...
I'm trying to test for the presence of some api response properties that I want to require across all tests (a status and data property).  Here's a generic test that asserts the desired properties in a supertest expect() method:      it('...
I have an express app like this:  server.js  const postsController = require('./controllers/posts_controller.js') module.exports = app = express() app.get('posts', postsController.index)   posts_controller.js  const post = require(...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.