Tuesday, 18 February 2020

Express/Jest testing API Framework Q's

I'm at my wits end, as I've attempted every tutorial on the first 2 page results of google and nothing seems to work right for me, or explained very well. I'm using Node.JS Express w/ Supertest and Jest. Any help would be appreciated:Most tutorials or guides have something like this: response.body.should.have.property(fieldName); However, this doesn't work for me, no matter which format I try. Each time it says cannot read property "fieldName" of undefined. I've read a bit about a body-parser, but I haven't had any luck there either.What is the proper way to use the app.js, and the request(app)? I've tried to understand, but I just cannot. I've been able to get a test working by just hardcoding like return request("myApiEndpoint").get('/path') but most guides have this app.js and I just don't understand that.I've resorted to using a .then(response =>.... series of asserts, because of the first point above not working for me. Is this fine? How scalable is this sort of thing?Edit: I'm using WebStorm for an IDE and on Windows atm

Submitted February 18, 2020 at 03:49PM by vegetto712

No comments:

Post a Comment