Skip to content

Commit

Permalink
chore(core): check for failures
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Apr 3, 2023
1 parent c415852 commit 90fd0c4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
4 changes: 2 additions & 2 deletions e2e/workspace-create-npm/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable */
export default {
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
'^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
globals: {},
displayName: 'e2e-workspace-create-npm',
preset: '../../jest.preset.js',
};
39 changes: 17 additions & 22 deletions e2e/workspace-create-npm/src/create-nx-workspace-npm.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
checkFilesExist,
cleanupProject,
e2eCwd,
getPackageManagerCommand,
getSelectedPackageManager,
packageInstall,
readJson,
Expand All @@ -9,23 +11,33 @@ import {
runCreateWorkspace,
uniq,
} from '@nrwl/e2e/utils';
import { execSync } from 'child_process';

describe('create-nx-workspace --preset=npm', () => {
const wsName = uniq('npm');
const packageManager = getSelectedPackageManager() || 'pnpm';

let originalVerbose;
beforeAll(() => {
originalVerbose = process.env.NX_VERBOSE_LOGGING;
process.env.NX_VERBOSE_LOGGING = 'true';
runCreateWorkspace(wsName, {
preset: 'npm',
packageManager,
packageManager: getSelectedPackageManager(),
});
});

beforeEach(() => {
runCommand(`git reset --hard`);
afterEach(() => {
runCommand(`git reset --hard HEAD`);
execSync(`${getPackageManagerCommand().runNx} reset`, {
cwd: `${e2eCwd}/${wsName}`,
stdio: 'pipe',
});
});

afterAll(() => cleanupProject());
afterAll(() => {
process.env.NX_VERBOSE_LOGGING = originalVerbose;
cleanupProject({ skipReset: true });
});

it('should add angular application', () => {
packageInstall('@nrwl/angular', wsName);
Expand Down Expand Up @@ -55,23 +67,6 @@ describe('create-nx-workspace --preset=npm', () => {
});
}, 1_000_000);

it('should add workspace library', () => {
packageInstall('@nrwl/workspace', wsName);

const libName = uniq('lib');

expect(() =>
runCLI(
`generate @nrwl/workspace:library ${libName} --skipPackageJson --no-interactive`
)
).not.toThrowError();
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
});
});

it('should add js library', () => {
packageInstall('@nrwl/js', wsName);

Expand Down
3 changes: 2 additions & 1 deletion packages/devkit/src/utils/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,10 @@ export function ensurePackage<T extends any = any>(
const tempDir = dirSync().name;

console.log(`Fetching ${pkg}...`);
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
execSync(`${getPackageManagerCommand().addDev} ${pkg}@${requiredVersion}`, {
cwd: tempDir,
stdio: 'ignore',
stdio: isVerbose ? 'inherit' : 'ignore',
});

addToNodePath(join(workspaceRoot, 'node_modules'));
Expand Down

0 comments on commit 90fd0c4

Please sign in to comment.