Unable to create a Pool instance with constructor in jest test

69
June 19, 2019, at 5:30 PM

When I run a jest test, creating a Pool instance when I require the pool, it returns a _pg.Pool is not a constructor error.

I have tried looking at the stackoverflow: pg.Pool is not a constructor

And this still does not work.

However, I am able to create a pool instance when I run the code, the error only shows up in Jest.

Node code:

import { Pool } from 'pg'
const pool = new Pool({configs})
export default pool

Error log:

‚óŹ Test suite failed to run
    TypeError: _pg.Pool is not a constructor
    > 6 | const pool = new Pool({
        |              
      at Object.<anonymous> (src/resources/connection.js:6:14)
      at Object.require (src/routes/api.js:2:20)
      at Object.<anonymous> (src/__tests__/integration/user.test.js:8:1)

sidenode: the code is a copy of the documentation in https://node-postgres.com/api/pool

I don't expect an error to occur, since pg.Pool is a class with a constructor.

READ ALSO
Cloud Build for Google App Engine - Flexible is failing with a generic &#39;exit status 1&#39;

Cloud Build for Google App Engine - Flexible is failing with a generic 'exit status 1'

I'm testing how to build a pipeline on GCP and after successfully deploying an Angular 6 application I wanted to add a websocket (socketio) backend that will serve real time updates

58
Returning pairs of _id&#39;s of duplicate docs found by a specific field on mongoDb

Returning pairs of _id's of duplicate docs found by a specific field on mongoDb

During DB data migration I'm running these days, I've found docs that remain in the collection that should not be there anymore

36
How can fix my EJS reference error: friend(variable) not defined?

How can fix my EJS reference error: friend(variable) not defined?

I'm creating a website called makeFriendWhen user adds a friend, the friend will be saved to the database

46
Segfault with Meteor + Passenger + Nginx

Segfault with Meteor + Passenger + Nginx

I have a Meteor app in production with Passenger+Nginx following this guide: https://wwwphusionpassenger

42