chore(repo): setup internal testing utils structure (#17043)

This commit is contained in:
Craigory Coppola 2023-05-16 11:34:10 -04:00 committed by GitHub
parent c7a6b4ba6c
commit cac64d7a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 211 additions and 228 deletions

View File

@ -1,15 +1,8 @@
import path = require('path'); import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
describe('Angular migrations', () => { describe('Angular migrations', () => {
it('should have valid paths', () => { assertValidMigrationPaths(json, __dirname);
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() =>
require.resolve(
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,14 +1,7 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
describe('Cypress migrations', () => { describe('Cypress migrations', () => {
it('should have valid paths', () => { assertValidMigrationPaths(json, __dirname);
Object.values(json.generators || {}).forEach((m: any) => {
expect(() =>
require.resolve(
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,14 +1,7 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
describe('Detox migrations', () => { describe('Detox migrations', () => {
it('should have valid paths', () => { assertValidMigrationPaths(json, __dirname);
Object.values(json.generators).forEach((m: any) => {
expect(() =>
require.resolve(
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -0,0 +1,3 @@
/* eslint-disable @typescript-eslint/no-restricted-imports */
export * from 'nx/internal-testing-utils/assert-valid-migrations';
export * from 'nx/internal-testing-utils/run-migration-against-this-workspace';

View File

@ -0,0 +1,7 @@
import json = require('./migrations.json');
import { assertValidMigrationPaths } from './internal-testing-utils';
describe('Devkit migrations', () => {
assertValidMigrationPaths(json, __dirname);
});

View File

@ -1,3 +1,4 @@
import { assertRunsAgainstNxRepo } from 'nx/internal-testing-utils/run-migration-against-this-workspace';
import { createTreeWithEmptyWorkspace } from 'nx/src/generators/testing-utils/create-tree-with-empty-workspace'; import { createTreeWithEmptyWorkspace } from 'nx/src/generators/testing-utils/create-tree-with-empty-workspace';
import { Tree } from 'nx/src/generators/tree'; import { Tree } from 'nx/src/generators/tree';
import { readJson, updateJson } from 'nx/src/generators/utils/json'; import { readJson, updateJson } from 'nx/src/generators/utils/json';
@ -35,4 +36,6 @@ describe('update-16-0-0-add-nx-packages', () => {
expect(newDependencyVersion).toBeDefined(); expect(newDependencyVersion).toBeDefined();
}); });
assertRunsAgainstNxRepo(replacePackage);
}); });

View File

@ -11,6 +11,7 @@
"**/*.test.ts", "**/*.test.ts",
"**/*_spec.ts", "**/*_spec.ts",
"**/*_test.ts", "**/*_test.ts",
"internal-testing-utils.ts",
"jest.config.ts" "jest.config.ts"
], ],
"files": ["./index.d.ts"], "files": ["./index.d.ts"],

View File

@ -17,6 +17,7 @@
"**/*.spec.jsx", "**/*.spec.jsx",
"**/*.test.jsx", "**/*.test.jsx",
"**/*.d.ts", "**/*.d.ts",
"internal-testing-utils.ts",
"jest.config.ts" "jest.config.ts"
] ]
} }

View File

@ -1,14 +1,7 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
describe('esbuild migrations', () => { describe('esbuild migrations', () => {
it('should have valid paths', () => { assertValidMigrationPaths(json, __dirname);
Object.values(json.generators).forEach((m: any) => {
expect(() =>
require.resolve(
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -0,0 +1,7 @@
import json = require('./migrations.json');
import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
describe('eslint-plugin migrations', () => {
assertValidMigrationPaths(json, __dirname);
});

View File

@ -0,0 +1,8 @@
import json = require('./migrations.json');
import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
import { MigrationsJson } from '@nx/devkit';
describe('expo migrations', () => {
assertValidMigrationPaths(json as MigrationsJson, __dirname);
});

View File

@ -1,14 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
describe('Express migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: any) => {
expect(() => describe('express migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Jest migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('jest migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,14 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
describe('JS migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: any) => {
expect(() => describe('js migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Linter migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('linter migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Nest migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('nest migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Next migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('next migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Node migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('node migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -0,0 +1,33 @@
import {
MigrationsJson,
MigrationsJsonEntry,
} from '../src/config/misc-interfaces';
import * as path from 'path';
export function assertValidMigrationPaths(json: MigrationsJson, root: string) {
Object.entries(json.generators).forEach(([generator, m]) => {
it(`should have valid path generator: ${generator}`, () => {
validateMigration(m, root);
});
});
Object.entries(json.schematics ?? {}).forEach(([schematic, m]) => {
it(`should have valid path schematic: ${schematic}`, () => {
validateMigration(m, root);
});
});
}
function validateMigration(m: MigrationsJsonEntry, root: string) {
const impl = m.factory ?? m.implementation;
const [implPath, implMember] = impl.includes('#')
? impl.split('#')
: [impl, null];
let implModule;
expect(() => {
implModule = require(path.join(root, `${implPath}.ts`));
}).not.toThrow();
if (implMember) {
expect(implModule).toHaveProperty(implMember);
}
}

View File

@ -0,0 +1,19 @@
import { FsTree, Tree } from '../src/generators/tree';
import { join } from 'path';
export function assertRunsAgainstNxRepo(
migrateFn: (tree: Tree) => void | Promise<void>
) {
it('should run against the Nx repo', async () => {
const tree = new FsTree(join(__dirname, '../../../'), true);
let resultOrPromise: void | Promise<void> = migrateFn(tree);
if (resultOrPromise && 'then' in resultOrPromise) {
try {
await resultOrPromise;
} catch (e) {
fail(e);
}
}
});
}

View File

@ -1,12 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
describe('Nx migrations', () => { import { assertValidMigrationPaths } from './internal-testing-utils/assert-valid-migrations';
it('should have valid paths', () => { import { MigrationsJson } from './src/config/misc-interfaces';
Object.values(json.generators).forEach((m) => {
expect(() => describe('nx migrations', () => {
require.resolve(path.join(__dirname, `${m.implementation}.ts`)) assertValidMigrationPaths(json as MigrationsJson, __dirname);
).not.toThrow();
});
});
}); });

View File

@ -76,7 +76,7 @@ export interface MigrationsJsonEntry {
export interface MigrationsJson { export interface MigrationsJson {
name?: string; name?: string;
version: string; version?: string;
collection?: string; collection?: string;
generators?: { [name: string]: MigrationsJsonEntry }; generators?: { [name: string]: MigrationsJsonEntry };
schematics?: { [name: string]: MigrationsJsonEntry }; schematics?: { [name: string]: MigrationsJsonEntry };

View File

@ -3,6 +3,7 @@ import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/cre
import { addProjectConfiguration } from '../../generators/utils/project-configuration'; import { addProjectConfiguration } from '../../generators/utils/project-configuration';
import { readJson, updateJson, writeJson } from '../../generators/utils/json'; import { readJson, updateJson, writeJson } from '../../generators/utils/json';
import removeRoots from './remove-roots'; import removeRoots from './remove-roots';
import { assertRunsAgainstNxRepo } from '../../../internal-testing-utils/run-migration-against-this-workspace';
describe('remove-roots >', () => { describe('remove-roots >', () => {
let tree: Tree; let tree: Tree;
@ -46,4 +47,6 @@ describe('remove-roots >', () => {
}); });
}); });
}); });
assertRunsAgainstNxRepo(removeRoots);
}); });

View File

@ -1,3 +1,4 @@
import { assertRunsAgainstNxRepo } from '../../../internal-testing-utils/run-migration-against-this-workspace';
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace'; import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
import type { Tree } from '../../generators/tree'; import type { Tree } from '../../generators/tree';
import { readJson, writeJson } from '../../generators/utils/json'; import { readJson, writeJson } from '../../generators/utils/json';
@ -58,4 +59,6 @@ describe('add-json-schema >', () => {
readJson(tree, 'libs/nested/test-two/project.json')['$schema'] readJson(tree, 'libs/nested/test-two/project.json')['$schema']
).toEqual('../../../node_modules/nx/schemas/project-schema.json'); ).toEqual('../../../node_modules/nx/schemas/project-schema.json');
}); });
assertRunsAgainstNxRepo(addJsonSchema);
}); });

View File

@ -4,6 +4,7 @@ import {
readNxJson, readNxJson,
updateNxJson, updateNxJson,
} from '../../generators/utils/project-configuration'; } from '../../generators/utils/project-configuration';
import { assertRunsAgainstNxRepo } from '../../../internal-testing-utils/run-migration-against-this-workspace';
import removeDefaultCollection from './remove-default-collection'; import removeDefaultCollection from './remove-default-collection';
describe('remove-default-collection', () => { describe('remove-default-collection', () => {
@ -52,4 +53,6 @@ describe('remove-default-collection', () => {
tree.delete('nx.json'); tree.delete('nx.json');
await expect(removeDefaultCollection(tree)).resolves.not.toThrow(); await expect(removeDefaultCollection(tree)).resolves.not.toThrow();
}); });
assertRunsAgainstNxRepo(removeDefaultCollection);
}); });

View File

@ -1,3 +1,4 @@
import { assertRunsAgainstNxRepo } from '../../../internal-testing-utils/run-migration-against-this-workspace';
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace'; import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
import type { Tree } from '../../generators/tree'; import type { Tree } from '../../generators/tree';
import { import {
@ -40,4 +41,6 @@ describe('createTargetDefaults', () => {
tree.delete('nx.json'); tree.delete('nx.json');
await expect(createTargetDefaults(tree)).resolves.not.toThrow(); await expect(createTargetDefaults(tree)).resolves.not.toThrow();
}); });
assertRunsAgainstNxRepo(createTargetDefaults);
}); });

View File

@ -1,3 +1,4 @@
import { assertRunsAgainstNxRepo } from '../../../internal-testing-utils/run-migration-against-this-workspace';
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace'; import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
import type { Tree } from '../../generators/tree'; import type { Tree } from '../../generators/tree';
import { import {
@ -451,4 +452,6 @@ describe('15.0.0 migration (migrate-to-inputs) (v1)', () => {
const lib = readProjectConfiguration(tree, 'lib1'); const lib = readProjectConfiguration(tree, 'lib1');
expect(lib.namedInputs).toBeUndefined(); expect(lib.namedInputs).toBeUndefined();
}); });
assertRunsAgainstNxRepo(migrateToInputs);
}); });

View File

@ -7,6 +7,7 @@ import {
import update from './update-depends-on-to-tokens'; import update from './update-depends-on-to-tokens';
import { updateJson, writeJson } from '../../generators/utils/json'; import { updateJson, writeJson } from '../../generators/utils/json';
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace'; import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
import { assertRunsAgainstNxRepo } from '../../../internal-testing-utils/run-migration-against-this-workspace';
describe('update-depends-on-to-tokens', () => { describe('update-depends-on-to-tokens', () => {
it('should update nx.json', async () => { it('should update nx.json', async () => {
@ -125,4 +126,6 @@ describe('update-depends-on-to-tokens', () => {
promise = update(tree); promise = update(tree);
await expect(promise).resolves.toBeUndefined(); await expect(promise).resolves.toBeUndefined();
}); });
assertRunsAgainstNxRepo(update);
}); });

View File

@ -5,6 +5,7 @@ import {
addProjectConfiguration, addProjectConfiguration,
readProjectConfiguration, readProjectConfiguration,
} from '../../generators/utils/project-configuration'; } from '../../generators/utils/project-configuration';
import { assertRunsAgainstNxRepo } from '../../../internal-testing-utils/run-migration-against-this-workspace';
import removeRunCommandsOutputPath from './remove-run-commands-output-path'; import removeRunCommandsOutputPath from './remove-run-commands-output-path';
describe('removeRunCommandsOutputPath', () => { describe('removeRunCommandsOutputPath', () => {
@ -96,4 +97,6 @@ describe('removeRunCommandsOutputPath', () => {
}); });
expect(migratedTargetDefaults.other).toEqual(startingTargetDefaults.other); expect(migratedTargetDefaults.other).toEqual(startingTargetDefaults.other);
}); });
assertRunsAgainstNxRepo(removeRunCommandsOutputPath);
}); });

View File

@ -10,7 +10,8 @@
"**/*.spec.ts", "**/*.spec.ts",
"**/*_spec.ts", "**/*_spec.ts",
"jest.config.ts", "jest.config.ts",
"**/__fixtures__/**/*.*" "**/__fixtures__/**/*.*",
"internal-testing-utils/**/*.ts"
], ],
"include": ["**/*.ts"] "include": ["**/*.ts"]
} }

View File

@ -12,6 +12,7 @@
"**/*.spec.js", "**/*.spec.js",
"**/*.spec.jsx", "**/*.spec.jsx",
"**/*.d.ts", "**/*.d.ts",
"internal-testing-utils/**/*.ts",
"jest.config.ts" "jest.config.ts"
] ]
} }

View File

@ -1,6 +1,7 @@
import { readJson, updateJson } from '@nx/devkit'; import { readJson, updateJson } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { Linter } from '@nx/linter'; import { Linter } from '@nx/linter';
import { assertRunsAgainstNxRepo } from '@nx/devkit/internal-testing-utils';
import { ExecutorConfig } from 'nx/src/config/misc-interfaces'; import { ExecutorConfig } from 'nx/src/config/misc-interfaces';
import executorGenerator from '../../generators/executor/executor'; import executorGenerator from '../../generators/executor/executor';
import pluginGenerator from '../../generators/plugin/plugin'; import pluginGenerator from '../../generators/plugin/plugin';
@ -50,6 +51,8 @@ describe('update-15-0-0-specify-output-capture', () => {
readJson<ExecutorConfig['schema']>(tree, schemaPath).outputCapture readJson<ExecutorConfig['schema']>(tree, schemaPath).outputCapture
).toEqual('direct-nodejs'); ).toEqual('direct-nodejs');
}); });
assertRunsAgainstNxRepo(update);
}); });
async function createTreeWithBoilerplate() { async function createTreeWithBoilerplate() {

View File

@ -1,5 +1,6 @@
import { Tree, readJson, updateJson } from '@nx/devkit'; import { Tree, readJson, updateJson } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { assertRunsAgainstNxRepo } from '@nx/devkit/internal-testing-utils';
import replacePackage from './update-16-0-0-add-nx-packages'; import replacePackage from './update-16-0-0-add-nx-packages';
describe('update-16-0-0-add-nx-packages', () => { describe('update-16-0-0-add-nx-packages', () => {
@ -34,4 +35,6 @@ describe('update-16-0-0-add-nx-packages', () => {
expect(newDependencyVersion).toBeDefined(); expect(newDependencyVersion).toBeDefined();
}); });
assertRunsAgainstNxRepo(replacePackage);
}); });

View File

@ -11,6 +11,7 @@ import {
} from '@nx/devkit'; } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { Linter } from '@nx/linter'; import { Linter } from '@nx/linter';
import { assertRunsAgainstNxRepo } from '@nx/devkit/internal-testing-utils';
import { PackageJson } from 'nx/src/utils/package-json'; import { PackageJson } from 'nx/src/utils/package-json';
import executorGenerator from '../../generators/executor/executor'; import executorGenerator from '../../generators/executor/executor';
import generatorGenerator from '../../generators/generator/generator'; import generatorGenerator from '../../generators/generator/generator';
@ -234,6 +235,8 @@ describe('updateCliPropsForPlugins', () => {
const updated = readJson(tree, schemaPath); const updated = readJson(tree, schemaPath);
expect(updated).not.toHaveProperty('cli'); expect(updated).not.toHaveProperty('cli');
}); });
assertRunsAgainstNxRepo(updateCliPropsForPlugins);
}); });
async function createPlugin(tree: Tree) { async function createPlugin(tree: Tree) {

View File

@ -5,6 +5,7 @@ import {
addProjectConfiguration, addProjectConfiguration,
readProjectConfiguration, readProjectConfiguration,
} from '@nx/devkit'; } from '@nx/devkit';
import { assertRunsAgainstNxRepo } from '@nx/devkit/internal-testing-utils';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import replaceE2EExecutor from './replace-e2e-executor'; import replaceE2EExecutor from './replace-e2e-executor';
@ -65,4 +66,6 @@ describe('update-16-0-0-add-nx-packages', () => {
} }
`); `);
}); });
assertRunsAgainstNxRepo(replaceE2EExecutor);
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('React Native migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('react-native migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('React migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('react migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Rollup migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('rollup migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Storybook migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('storybook migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Vite migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('vite migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Web migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('web migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,15 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
import { MigrationsJsonEntry } from 'nx/src/config/misc-interfaces';
describe('Webpack migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: MigrationsJsonEntry) => {
expect(() => describe('webpack migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.factory ?? m.implementation}.ts`)
)
).not.toThrow();
});
});
}); });

View File

@ -1,14 +1,8 @@
import path = require('path');
import json = require('./migrations.json'); import json = require('./migrations.json');
describe('Workspace migrations', () => { import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils';
it('should have valid paths', () => { import { MigrationsJson } from '@nx/devkit';
Object.values(json.generators).forEach((m: any) => {
expect(() => describe('workspace migrations', () => {
require.resolve( assertValidMigrationPaths(json as MigrationsJson, __dirname);
path.join(__dirname, `${m.implementation || m.factory}.ts`)
)
).not.toThrow();
});
});
}); });