diff --git a/package-lock.json b/package-lock.json index c890f82..abec588 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/core", - "version": "4.24.0", + "version": "4.25.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/core", - "version": "4.24.0", + "version": "4.25.0", "license": "MIT", "dependencies": { "pretty-repl": "^3.1.2", diff --git a/package.json b/package.json index f7f03a0..2ae817f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/core", - "version": "4.24.0", + "version": "4.25.0", "description": "The plug and play Node.js framework.", "license": "MIT", "author": "João Lenon ", diff --git a/src/testing/BaseConsoleTest.ts b/src/testing/BaseConsoleTest.ts index d698bfc..6a470a5 100644 --- a/src/testing/BaseConsoleTest.ts +++ b/src/testing/BaseConsoleTest.ts @@ -7,12 +7,14 @@ * file that was distributed with this source code. */ -import { Options } from '@athenna/common' -import { BeforeAll } from '@athenna/test' +import { Json, Options } from '@athenna/common' +import { AfterAll, BeforeAll } from '@athenna/test' import { Ignite, type IgniteOptions } from '@athenna/core' import { TestCommand } from '@athenna/artisan/testing/plugins' export class BaseConsoleTest { + private env = Json.copy(process.env) + private config = Json.copy(Config.get()) public ignite: Ignite public igniteOptions: IgniteOptions = {} public artisanPath: string = Path.bootstrap(`artisan.${Path.ext()}`) @@ -27,6 +29,15 @@ export class BaseConsoleTest { ) } + @AfterAll() + public async baseAfterAll() { + ioc.reconstruct() + process.env = Json.copy(this.env) + Object.keys(this.config).forEach(key => + Config.set(key, Json.copy(this.config[key])) + ) + } + private getIgniteOptions() { return Options.create(this.igniteOptions, { bootLogs: false, diff --git a/src/testing/BaseHttpTest.ts b/src/testing/BaseHttpTest.ts index b72d9a5..32fd443 100644 --- a/src/testing/BaseHttpTest.ts +++ b/src/testing/BaseHttpTest.ts @@ -7,12 +7,14 @@ * file that was distributed with this source code. */ -import { Options } from '@athenna/common' import { ServerImpl } from '@athenna/http' +import { Json, Options } from '@athenna/common' import { AfterAll, BeforeAll } from '@athenna/test' import { Ignite, type HttpOptions, type IgniteOptions } from '@athenna/core' export class BaseHttpTest { + private env = Json.copy(process.env) + private config = Json.copy(Config.get()) public ignite: Ignite public httpServer: ServerImpl public httpOptions: HttpOptions = {} @@ -31,6 +33,11 @@ export class BaseHttpTest { @AfterAll() public async baseAfterAll() { await this.httpServer.close() + ioc.reconstruct() + process.env = Json.copy(this.env) + Object.keys(this.config).forEach(key => + Config.set(key, Json.copy(this.config[key])) + ) } private getHttpOptions() {