Skip to content

Commit

Permalink
feat(testing): update jest-preset-angular to v8.0.0 part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Jan 29, 2020
1 parent 4068368 commit 03dae37
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
12 changes: 6 additions & 6 deletions packages/jest/migrations.json
Expand Up @@ -10,15 +10,15 @@
"description": "Update Jest testPathPattern option",
"factory": "./src/migrations/update-8-7-0/update-8-7-0"
},
"update-8.10.0": {
"version": "8.10.0",
"description": "Upgrades jest-preset-angular and runs migrations for breaking changes",
"factory": "./src/migrations/update-8-10-0/update-8-10-0"
"update-8.13.0": {
"version": "8.13.0",
"description": "Upgrades jest-preset-angular to 8.0.0",
"factory": "./src/migrations/update-8-13-0/update-8-13-0"
}
},
"packageJsonUpdates": {
"8.10.0": {
"version": "8.10.0-beta.1",
"8.13.0": {
"version": "8.13.0-beta.1",
"packages": {
"jest-preset-angular": {
"version": "8.0.0",
Expand Down
Expand Up @@ -26,7 +26,7 @@ export default function update(): Rule {
displayInformation,
updatePackagesInPackageJson(
path.join(__dirname, '../../../', 'migrations.json'),
'8.10.0'
'8.13.0'
),
updateJestConfigs,
formatFiles()
Expand Down Expand Up @@ -54,18 +54,28 @@ function updateJestConfigs(host: Tree) {
const workspaceConfig = readWorkspace(host);
const jestConfigsToUpdate = [];

Object.keys(workspaceConfig.projects).forEach(name => {
const project = workspaceConfig.projects[name];
if (
project.architect &&
project.architect.test &&
project.architect.test.builder === '@nrwl/jest:jest' &&
project.architect.test.options &&
project.architect.test.options.jestConfig ===
project.root + 'jest.config.js'
) {
jestConfigsToUpdate.push(project.root + 'jest.config.js');
Object.values<any>(workspaceConfig.projects).forEach(project => {
if (!project.architect) {
return;
}

Object.values<any>(project.architect).forEach(target => {
if (target.builder !== '@nrwl/jest:jest') {
return;
}

if (target.options.jestConfig) {
jestConfigsToUpdate.push(target.options.jestConfig);
}

if (target.configurations) {
Object.values<any>(target.configurations).forEach(config => {
if (config.jestConfig) {
jestConfigsToUpdate.push(config.jestConfig);
}
});
}
});
});

jestConfigsToUpdate.forEach(configPath => {
Expand Down

0 comments on commit 03dae37

Please sign in to comment.