Skip to content

Commit

Permalink
fix(repo): fix add-to-monorepo test (#10333)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed May 17, 2022
1 parent 7f5137d commit 0c8eade
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions e2e/cli/src/cli.test.ts
@@ -1,4 +1,5 @@
import {
isNotWindows,
newProject,
readFile,
readJson,
Expand Down Expand Up @@ -344,33 +345,36 @@ describe('migrate', () => {
});

it('should run migrations and create individual git commits using a provided custom commit prefix', () => {
runCLI(
'migrate migrate-parent-package@2.0.0 --from="migrate-parent-package@1.0.0"',
{
env: {
...process.env,
NX_MIGRATE_SKIP_INSTALL: 'true',
NX_MIGRATE_USE_LOCAL: 'true',
},
}
);
// Windows has shell escaping issues so this test would always fail
if (isNotWindows()) {
runCLI(
'migrate migrate-parent-package@2.0.0 --from="migrate-parent-package@1.0.0"',
{
env: {
...process.env,
NX_MIGRATE_SKIP_INSTALL: 'true',
NX_MIGRATE_USE_LOCAL: 'true',
},
}
);

// runs migrations with createCommits enabled and custom commit-prefix (NOTE: the extra quotes are needed here to avoid shell escaping issues)
runCLI(
`migrate --run-migrations=migrations.json --create-commits --commit-prefix="'chore(core): AUTOMATED - '"`,
{
env: {
...process.env,
NX_MIGRATE_SKIP_INSTALL: 'true',
NX_MIGRATE_USE_LOCAL: 'true',
},
}
);
// runs migrations with createCommits enabled and custom commit-prefix (NOTE: the extra quotes are needed here to avoid shell escaping issues)
runCLI(
`migrate --run-migrations=migrations.json --create-commits --commit-prefix="'chore(core): AUTOMATED - '"`,
{
env: {
...process.env,
NX_MIGRATE_SKIP_INSTALL: 'true',
NX_MIGRATE_USE_LOCAL: 'true',
},
}
);

const recentCommits = runCommand('git --no-pager log --oneline -n 10');
const recentCommits = runCommand('git --no-pager log --oneline -n 10');

expect(recentCommits).toContain('chore(core): AUTOMATED - run11');
expect(recentCommits).toContain('chore(core): AUTOMATED - run20');
expect(recentCommits).toContain('chore(core): AUTOMATED - run11');
expect(recentCommits).toContain('chore(core): AUTOMATED - run20');
}
});

it('should fail if a custom commit prefix is provided when --create-commits is not enabled', () => {
Expand Down

0 comments on commit 0c8eade

Please sign in to comment.