File tree 3 files changed +13
-9
lines changed
3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
10
10
} from '../btc-faucet' ;
11
11
import { ApiServer , startApiServer } from '../api/init' ;
12
12
import { ChainID } from '@stacks/transactions' ;
13
- import { cycleMigrations , PgDataStore } from '../datastore/postgres-store' ;
13
+ import { cycleMigrations , PgDataStore , runMigrations } from '../datastore/postgres-store' ;
14
14
15
15
async function getBalanceWithWalletImport ( address : string ) : Promise < number > {
16
16
const client = getRpcClient ( ) ;
@@ -102,11 +102,11 @@ describe('btc faucet', () => {
102
102
103
103
describe ( 'faucet http API' , ( ) => {
104
104
let apiServer : ApiServer ;
105
-
105
+ let db : PgDataStore ;
106
106
beforeAll ( async ( ) => {
107
107
process . env . PG_DATABASE = 'postgres' ;
108
108
await cycleMigrations ( ) ;
109
- const db = await PgDataStore . connect ( ) ;
109
+ db = await PgDataStore . connect ( ) ;
110
110
apiServer = await startApiServer ( {
111
111
datastore : db ,
112
112
chainId : ChainID . Testnet ,
@@ -144,6 +144,8 @@ describe('btc faucet', () => {
144
144
145
145
afterAll ( async ( ) => {
146
146
await apiServer . terminate ( ) ;
147
+ await db ?. close ( ) ;
148
+ await runMigrations ( undefined , 'down' ) ;
147
149
} ) ;
148
150
} ) ;
149
151
} ) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default async (): Promise<void> => {
28
28
} ,
29
29
httpLogLevel : 'silly' ,
30
30
} ) ;
31
- Object . assign ( global , { server : server } ) ;
31
+ Object . assign ( global , { server : server , db : db } ) ;
32
32
console . log ( 'Waiting for RPC connection to core node..' ) ;
33
33
await new StacksCoreRpcClient ( ) . waitForConnection ( 60000 ) ;
34
34
console . log ( 'Jest - setup done' ) ;
Original file line number Diff line number Diff line change 1
1
import * as isCI from 'is-ci' ;
2
+ import { PgDataStore } from '../datastore/postgres-store' ;
2
3
3
4
// ts-unused-exports:disable-next-line
4
5
export default async ( ) : Promise < void > => {
5
6
console . log ( 'Jest - teardown..' ) ;
6
7
const eventSocketServer : import ( 'net' ) . Server = ( global as any ) . server ;
7
- await new Promise < void > ( resolve => {
8
- eventSocketServer . close ( ( ) => {
9
- console . log ( 'Jest - teardown done' ) ;
10
- resolve ( ) ;
11
- } ) ;
8
+ const database : PgDataStore = ( global as any ) . db ;
9
+ await new Promise < void > ( async resolve => {
10
+ eventSocketServer . close ( ) ;
11
+ await database . close ( ) ;
12
+ console . log ( 'Jest - teardown done' ) ;
13
+ resolve ( ) ;
12
14
} ) ;
13
15
14
16
// If running in CI setup the "why am I still running?" log to detect stuck Jest tests
You can’t perform that action at this time.
0 commit comments