Skip to content

Commit

Permalink
fix(core): fix preset unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Apr 18, 2023
1 parent 00f424a commit 6b5ddae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 32 deletions.
17 changes: 14 additions & 3 deletions e2e/workspace-create/src/create-nx-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ describe('create-nx-plugin', () => {

it('should be able to create a plugin repo build a plugin', () => {
const pluginName = uniq('plugin');
const generatorName = uniq('generator');
const executorName = uniq('executor');

runCreatePlugin(pluginName, {
packageManager,
Expand All @@ -24,9 +26,18 @@ describe('create-nx-plugin', () => {
checkFilesExist(
'package.json',
packageManagerLockFile[packageManager],
`project.json`,
`generators.json`,
`executors.json`
`project.json`
);

runCLI(`build ${pluginName}`);

checkFilesExist(`dist/package.json`);

runCLI(
`generate @nrwl/nx-plugin:generator ${generatorName} --project=${pluginName}`
);
runCLI(
`generate @nrwl/nx-plugin:executor ${executorName} --project=${pluginName}`
);

runCLI(`build ${pluginName}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exports[`preset should create files (preset = react-standalone bundler = vite) 1
},
},
"defaultConfiguration": "development",
"executor": "@nrwl/vite:dev-server",
"executor": "@nx/vite:dev-server",
"options": {
"buildTarget": "proj:build",
},
Expand Down
28 changes: 0 additions & 28 deletions packages/workspace/src/generators/preset/preset.spec.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,13 @@
import { readProjectConfiguration, Tree } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { overrideCollectionResolutionForTesting } from '@nx/devkit/ngcli-adapter';
import { presetGenerator } from './preset';
import * as path from 'path';
import { Preset } from '../utils/presets';

describe('preset', () => {
let tree: Tree;

beforeEach(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
overrideCollectionResolutionForTesting({
'@nx/workspace': path.join(
__dirname,
'../../../../workspace/generators.json'
),
'@nx/angular': path.join(
__dirname,
'../../../../angular/generators.json'
),
'@nx/linter': path.join(__dirname, '../../../../linter/generators.json'),
'@nx/nest': path.join(__dirname, '../../../../nest/generators.json'),
'@nx/node': path.join(__dirname, '../../../../node/generators.json'),
'@nx/jest': path.join(__dirname, '../../../../jest/generators.json'),
'@nx/cypress': path.join(
__dirname,
'../../../../cypress/generators.json'
),
'@nx/express': path.join(
__dirname,
'../../../../express/generators.json'
),
});
});

afterEach(() => {
overrideCollectionResolutionForTesting(null);
});

it(`should create files (preset = ${Preset.AngularMonorepo})`, async () => {
Expand Down

0 comments on commit 6b5ddae

Please sign in to comment.