You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My query update not execute, and I get response back like this, after running my test, how to fix it this issue ?
TypeError: [(intermediate value)(intermediate value),(intermediate value)(intermediate value)][(step - 1)] is not a function
at Tracker.<anonymous> (/home/antimalware/Desktop/real-project/testing/src/__tests__/unit-test/05.customer.spec.ts:466:16)
at Tracker.emit (events.js:314:20)
at Tracker.EventEmitter.emit (domain.js:483:12)
at Queries.track (/home/antimalware/Desktop/real-project/testing/node_modules/mock-knex/dist/queries.js:68:22)
at /home/antimalware/Desktop/real-project/testing/node_modules/mock-knex/dist/platforms/knex/0.8/index.js:52:38
at Promise._execute (/home/antimalware/Desktop/real-project/testing/node_modules/bluebird/js/release/debuggability.js:303:9)
at Promise._resolveFromExecutor (/home/antimalware/Desktop/real-project/testing/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/home/antimalware/Desktop/real-project/testing/node_modules/bluebird/js/release/promise.js:79:10)
at Client_PG._query (/home/antimalware/Desktop/real-project/testing/node_modules/mock-knex/dist/platforms/knex/0.8/index.js:51:10)
at Client_PG.query (/home/antimalware/Desktop/real-project/testing/node_modules/knex/lib/client.js:168:17)
at /home/antimalware/Desktop/real-project/testing/node_modules/knex/lib/transaction.js:325:24
at new Promise (<anonymous>)
at Client_PG.trxClient.query (/home/antimalware/Desktop/real-project/testing/node_modules/knex/lib/transaction.js:320:12)
at Transaction.query (/home/antimalware/Desktop/real-project/testingt/node_modules/knex/lib/transaction.js:121:8)
at Transaction.rollback (/home/antimalware/Desktop/real-project/testing/node_modules/knex/lib/transaction.js:97:25)
at Function.transactor.rollback (/home/antimalware/Desktop/real-project/testing/node_modules/knex/lib/transaction.js:277:42)
at /home/antimalware/Desktop/real-project/testing/node_modules/knex/lib/transaction.js:193:35
My Testing
it('[POST] - /customer/verified-document/:customerId - Should be update verified document success',asyncfunction(){req.params.customerId=mockData.registerCustomer.success.idreq.body=mockData.registerCustomer.successmockData.registerCustomer.success.guarantor_identification_front_verified=falsemockData.registerCustomer.success.guarantor_identification_back_verified=falsemockData.registerCustomer.success.license_front_verified=falsemockData.registerCustomer.success.license_back_verified=falsemockData.registerCustomer.success.guarantor_identification_front_verified=falsemockData.registerCustomer.success.guarantor_identification_back_verified=falsetracker.on('query',(query,step)=>{return[()=>{if(query.method!==undefined&&step===2)chai.expect(query.method).to.equal('first')query.response(mockData.registerCustomer.success)},()=>{if(query.method!==undefined&&step===3)chai.expect(query.method).to.equal('update')query.response(1)}][step-1]()})awaitverifiedCustomerDocument(req,res)constdata=res._getJSONData()chai.expect(res._isEndCalled()).to.be.truechai.expect(res._getStatusCode()).to.be.equal(200)chai.expect(res._getHeaders()).to.be.contain({'content-type': 'application/json'})chai.expect(data.message).to.be.equal(`Successfully verified customer document.`)})
My Controller
import{checkSchema}from'express-validator'import{ApiRequest,ApiResponse}from'../../interface/common'import{Customer}from'../../interface/model'importdbfrom'../../lib/db'
export asyncfunctionverifiedCustomerDocument(req: ApiRequest,res: ApiResponse): Promise<any>{let params =req.paramsletpayload=req.bodytry{awaitdb.transaction(async(trx)=>{constcheckVerifiedDocument=awaittrx<Customer>('customer').where({userId: params.customerId}).first()if(checkVerifiedDocument===undefined){throw{status: 'ERROR',httpStatus: 404,error: 'UPDATE_VERIFIED_DOCUMENT',code: '1EC5OXWO',message: `Customer data not found for this id ${params.customerId}`}}if(checkVerifiedDocument?.identificationFrontVerified===true){throw{status: 'ERROR',httpStatus: 403,error: 'UPDATE_VERIFIED_DOCUMENT',code: '1EC5OXWO',message: 'Customer identificationFront is verified'}}elseif(checkVerifiedDocument?.identificationBackVerified===true){throw{status: 'ERROR',httpStatus: 403,error: 'UPDATE_VERIFIED_DOCUMENT',code: '1EC5OXWO',message: 'Customer identificationBack is verified'}}elseif(checkVerifiedDocument?.licenseFrontVerified===true){throw{status: 'ERROR',httpStatus: 403,error: 'UPDATE_VERIFIED_DOCUMENT',code: '1EC5OXWO',message: 'Customer licenseFront is verified'}}elseif(checkVerifiedDocument?.licenseBackVerified===true){throw{status: 'ERROR',httpStatus: 403,error: 'UPDATE_VERIFIED_DOCUMENT',code: '1EC5OXWO',message: 'Customer licenseBack is verified'}}elseif(checkVerifiedDocument?.guarantorIdentificationFrontVerified===true){throw{status: 'ERROR',httpStatus: 403,error: 'UPDATE_VERIFIED_DOCUMENT',code: '1EC5OXWO',message: 'Customer guarantorIdentificationFront is verified'}}elseif(checkVerifiedDocument?.guarantorIdentificationBackVerified===true){throw{status: 'ERROR',httpStatus: 403,error: 'UPDATE_VERIFIED_DOCUMENT',code: '1EC5OXWO',message: 'Customer guarantorIdentificationBack is verified'}}else{constupdateVerifiedDoc=awaittrx<Customer>('customer').where({userId: params.customerId}).update({identificationFrontVerified: payload.identificationFrontVerified,identificationBackVerified: payload.identificationBackVerified,licenseFrontVerified: payload.licenseFrontVerified,licenseBackVerified: payload.licenseBackVerified,otherDocumentVerified: payload.otherDocumentVerified,guarantorIdentificationFrontVerified: payload.guarantorIdentificationFrontVerified,guarantorIdentificationBackVerified: payload.guarantorIdentificationBackVerified})if(updateVerifiedDoc<1){throw{httpStatus: 403,status: 'ERROR',code: 'XCD3221',message: 'Failed update customer verified document'}}constjson={status: 'OK',message: 'Successfully verified customer document.'}res.status(200).json(json)returnjson}})}catch(err){console.error(err)constjson={httpStatus: 400,status: 'ERROR',code: err.code||'1EC5OXWO',message: err.message||'UPDATE_VERIFIED_DOCUMENT'}res.status(err.httpStatus||400).json(json)returnjson}}})
The text was updated successfully, but these errors were encountered:
My query update not execute, and I get response back like this, after running my test, how to fix it this issue ?
My Testing
My Controller
The text was updated successfully, but these errors were encountered: