Skip to content

Commit

Permalink
fix(angular): mfe migration failing in certain scenarios (#8384)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Jan 5, 2022
1 parent 8a0010b commit 0f50de7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ import updateMfeConfig, { removeRemoteName } from './update-mfe-webpack-config';

describe('update-mfe-webpack-config', () => {
describe('run the migration', () => {
it('should skip the migration when there is no MFE config', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);
addProjectConfiguration(tree, 'app', {
root: 'apps/testing',
targets: {
build: {
executor: '@nrwl/angular:webpack-browser',
options: {},
},
serve: {
executor: '@nrwl/angular:webpack-server',
options: {
port: 4201,
},
},
},
});

// ACT
let error = undefined;
try {
await updateMfeConfig(tree);
} catch (err) {
error = err;
}

// ASSERT
expect(error).toBeUndefined();
});

it('should skip the migration when using a different executor', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);
addProjectConfiguration(tree, 'app', {
root: 'apps/testing',
targets: {
build: {
executor: '@angular-devkit/build-angular',
},
},
});

// ACT
let error = undefined;
try {
await updateMfeConfig(tree);
} catch (err) {
error = err;
}

// ASSERT
expect(error).toBeUndefined();
});

it('shouldnt run for non mfe configs', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function (tree: Tree) {
(opts, projectName) => {
// Update the webpack config
const webpackPath = opts[CUSTOM_WEBPACK_OPTION]?.path;
if (!tree.exists(webpackPath)) {
if (!webpackPath || !tree.exists(webpackPath)) {
logger.warn(
`Webpack config file for project: ${projectName} does not exist. Skipping project.`
);
Expand Down

0 comments on commit 0f50de7

Please sign in to comment.