Skip to content

Commit

Permalink
tests: move consts project configuration to fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianRomanski committed Dec 20, 2024
1 parent 2e749e3 commit a78f6c4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -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<ProjectConfiguration>
> = {
mockKey: MOCK_PROJECT_CONFIGURATION,
};
2 changes: 1 addition & 1 deletion projects/nx-verdaccio/src/plugin/caching.unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ 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,
setCacheRecord,
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<
Expand Down
63 changes: 0 additions & 63 deletions testing/test-utils/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -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<ProjectConfiguration>
> = {
mockKey: MOCK_PROJECT_CONFIGURATION,
};

0 comments on commit a78f6c4

Please sign in to comment.