diff --git a/projects/nx-verdaccio/src/fixtures/project-configuration.fixture.ts b/projects/nx-verdaccio/src/fixtures/project-configuration.fixture.ts new file mode 100644 index 0000000..3ca4ba3 --- /dev/null +++ b/projects/nx-verdaccio/src/fixtures/project-configuration.fixture.ts @@ -0,0 +1,62 @@ +import type { ProjectConfiguration } from '@nx/devkit'; + +const MOCK_PROJECT_CONFIGURATION: ProjectConfiguration = { + name: 'mock-project', + root: 'apps/mock-project', + sourceRoot: 'apps/mock-project/src', + projectType: 'application', + tags: ['e2e', 'unit-test'], + implicitDependencies: ['shared-library'], + targets: { + build: { + executor: '@nx/web:build', + options: { + outputPath: 'dist/apps/mock-project', + index: 'apps/mock-project/src/index.html', + main: 'apps/mock-project/src/main.ts', + tsConfig: 'apps/mock-project/tsconfig.app.json', + }, + configurations: { + production: { + fileReplacements: [ + { + replace: 'apps/mock-project/src/environments/environment.ts', + with: 'apps/mock-project/src/environments/environment.prod.ts', + }, + ], + optimization: true, + sourceMap: false, + }, + }, + }, + }, + generators: { + '@nx/react': { + library: { + style: 'scss', + }, + }, + }, + namedInputs: { + default: ['{projectRoot}/**/*', '!{projectRoot}/**/*.spec.ts'], + production: ['default', '!{projectRoot}/**/*.test.ts'], + }, + release: { + version: { + generator: '@nx/version', + generatorOptions: { + increment: 'minor', + }, + }, + }, + metadata: { + description: 'This is a mock project for testing.', + }, +}; + +export const MOCK_TARGETS_CACHE: Record< + string, + Partial +> = { + mockKey: MOCK_PROJECT_CONFIGURATION, +}; diff --git a/projects/nx-verdaccio/src/plugin/caching.unit-test.ts b/projects/nx-verdaccio/src/plugin/caching.unit-test.ts index e1117a7..18dc064 100644 --- a/projects/nx-verdaccio/src/plugin/caching.unit-test.ts +++ b/projects/nx-verdaccio/src/plugin/caching.unit-test.ts @@ -9,7 +9,6 @@ import * as nodeFs from 'node:fs'; import * as nxDevKit from '@nx/devkit'; import { type ProjectConfiguration } from '@nx/devkit'; import { type JsonReadOptions } from 'nx/src/utils/fileutils'; -import { MOCK_TARGETS_CACHE } from '@push-based/test-utils'; import { getCacheRecord, readTargetsCache, @@ -17,6 +16,7 @@ import { writeTargetsToCache, } from './caching'; import * as cachingUtils from './utils/caching.utils'; +import { MOCK_TARGETS_CACHE } from '../fixtures/project-configuration.fixture'; describe('cacheRecord', (): void => { let cacheKeySpy: MockInstance< diff --git a/testing/test-utils/src/lib/constants.ts b/testing/test-utils/src/lib/constants.ts index b5c9ebf..e6d5cd0 100644 --- a/testing/test-utils/src/lib/constants.ts +++ b/testing/test-utils/src/lib/constants.ts @@ -1,64 +1 @@ -import type { ProjectConfiguration } from '@nx/devkit'; - export const MEMFS_VOLUME = '/test'; - -const MOCK_PROJECT_CONFIGURATION: ProjectConfiguration = { - name: 'mock-project', - root: 'apps/mock-project', - sourceRoot: 'apps/mock-project/src', - projectType: 'application', - tags: ['e2e', 'unit-test'], - implicitDependencies: ['shared-library'], - targets: { - build: { - executor: '@nx/web:build', - options: { - outputPath: 'dist/apps/mock-project', - index: 'apps/mock-project/src/index.html', - main: 'apps/mock-project/src/main.ts', - tsConfig: 'apps/mock-project/tsconfig.app.json', - }, - configurations: { - production: { - fileReplacements: [ - { - replace: 'apps/mock-project/src/environments/environment.ts', - with: 'apps/mock-project/src/environments/environment.prod.ts', - }, - ], - optimization: true, - sourceMap: false, - }, - }, - }, - }, - generators: { - '@nx/react': { - library: { - style: 'scss', - }, - }, - }, - namedInputs: { - default: ['{projectRoot}/**/*', '!{projectRoot}/**/*.spec.ts'], - production: ['default', '!{projectRoot}/**/*.test.ts'], - }, - release: { - version: { - generator: '@nx/version', - generatorOptions: { - increment: 'minor', - }, - }, - }, - metadata: { - description: 'This is a mock project for testing.', - }, -}; - -export const MOCK_TARGETS_CACHE: Record< - string, - Partial -> = { - mockKey: MOCK_PROJECT_CONFIGURATION, -};