mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
parent
2da196cc1f
commit
e8280d58f6
24
packages/pg-esm-test/common-js-imports.test.cjs
Normal file
24
packages/pg-esm-test/common-js-imports.test.cjs
Normal file
@ -0,0 +1,24 @@
|
||||
const assert = require('node:assert')
|
||||
const test = require('node:test')
|
||||
const { describe, it } = test
|
||||
|
||||
const paths = ['pg', 'pg/lib/index.js', 'pg/lib/connection-parameters.js']
|
||||
for (const path of paths) {
|
||||
describe(`importing ${path}`, () => {
|
||||
it('works with require', () => {
|
||||
const mod = require(path)
|
||||
assert(mod)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
describe('pg-native', () => {
|
||||
it('should work with commonjs', async () => {
|
||||
const pg = require('pg')
|
||||
|
||||
const pool = new pg.native.Pool()
|
||||
const result = await pool.query('SELECT 1')
|
||||
assert.strictEqual(result.rowCount, 1)
|
||||
pool.end()
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user