From 0e6a61dd882f103b40bce38577fd7e7bcf44309a Mon Sep 17 00:00:00 2001 From: Romanchuk Sergey Date: Fri, 1 Dec 2023 13:09:48 +0700 Subject: [PATCH] fix: nx and jest setup --- .../src/app/app.component.spec.ts | 2 +- libs/angular-i18next/src/test-setup.ts | 12 +++++++- nx.json | 28 +++++++------------ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/apps/angular-i18next-demo/src/app/app.component.spec.ts b/apps/angular-i18next-demo/src/app/app.component.spec.ts index a0f2eb3..c526b40 100644 --- a/apps/angular-i18next-demo/src/app/app.component.spec.ts +++ b/apps/angular-i18next-demo/src/app/app.component.spec.ts @@ -3,7 +3,7 @@ import { AppComponent } from './app.component'; import { RouterTestingModule } from '@angular/router/testing'; describe('AppComponent', () => { - beforeEach(async () => { + beforeEach(waitForAsync(() => { await TestBed.configureTestingModule({ imports: [RouterTestingModule], declarations: [AppComponent], diff --git a/libs/angular-i18next/src/test-setup.ts b/libs/angular-i18next/src/test-setup.ts index 5553a4a..ab3e021 100644 --- a/libs/angular-i18next/src/test-setup.ts +++ b/libs/angular-i18next/src/test-setup.ts @@ -1 +1,11 @@ -import 'jest-preset-angular/setup-jest'; \ No newline at end of file +import 'jest-preset-angular/setup-jest'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; + +getTestBed().resetTestEnvironment(); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + teardown: { destroyAfterEach: false }, +}); diff --git a/nx.json b/nx.json index decbf3f..737fcd3 100644 --- a/nx.json +++ b/nx.json @@ -1,24 +1,7 @@ { - "npmScope": "angular-i18next", "affected": { "defaultBase": "master" }, - "implicitDependencies": { - "package.json": { - "dependencies": "*", - "devDependencies": "*" - }, - ".eslintrc.json": "*" - }, - "tasksRunnerOptions": { - "default": { - "runner": "nx/tasks-runners/default", - "options": { - "cacheableOperations": ["build", "lint", "test", "e2e"] - } - } - }, - "targetDependencies": { "build": [ { @@ -64,7 +47,8 @@ "cache": true }, "build": { - "cache": true + "cache": true, + "inputs": ["production", "^production"] }, "e2e": { "cache": true @@ -81,6 +65,14 @@ "codeCoverage": true } } + }, + "test": { + "cache": true } + }, + "namedInputs": { + "default": ["{projectRoot}/**/*", "sharedGlobals"], + "sharedGlobals": [], + "production": ["default"] } }