Use real cls-hooked in tests instead of NamespaceMock
https://github.com/Jeff-Lewis/cls-hooked/issues/17#issuecomment-510168720 Note: uses undocumented methods ns.enter(context) and ns.exit(context)
This commit is contained in:
parent
e2c8fca29b
commit
772c3f6682
@ -39,7 +39,11 @@ export class TestUtils<T extends IRoutes> {
|
||||
let connection!: Connection
|
||||
let queryRunner: QueryRunner
|
||||
|
||||
let context: any
|
||||
|
||||
beforeEach(async () => {
|
||||
context = namespace.createContext();
|
||||
(namespace as any).enter(context)
|
||||
connection = await database.connect()
|
||||
queryRunner = connection.createQueryRunner()
|
||||
await queryRunner.connect()
|
||||
@ -56,7 +60,8 @@ export class TestUtils<T extends IRoutes> {
|
||||
await queryRunner.release()
|
||||
namespace.set(CORRELATION_ID, undefined)
|
||||
namespace.set(ENTITY_MANAGER, undefined)
|
||||
await connection.close()
|
||||
await connection.close();
|
||||
(namespace as any).exit(context)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
import {Bootstrap} from './application/Bootstrap'
|
||||
import {IAPIDef} from '@rondo.dev/common'
|
||||
import {NamespaceMock, TestUtils} from './test-utils'
|
||||
import {TestUtils} from './test-utils'
|
||||
import {config} from './config'
|
||||
import {createNamespace} from 'cls-hooked'
|
||||
|
||||
export const exit = jest.fn()
|
||||
|
||||
const bootstrap = new Bootstrap(
|
||||
config,
|
||||
new NamespaceMock(),
|
||||
createNamespace('test'),
|
||||
exit,
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user