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 31, 2020
1 parent 4068368 commit a482722
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .prettierrc
@@ -1,4 +1,4 @@
{
"singleQuote": true,
"endOfLine": "lf"
}
{
"singleQuote": true,
"endOfLine": "lf"
}
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-9.0.0": {
"version": "9.0.0",
"description": "Upgrades jest-preset-angular to 8.0.0",
"factory": "./src/migrations/update-9-0-0/update-9-0-0"
}
},
"packageJsonUpdates": {
"8.10.0": {
"version": "8.10.0-beta.1",
"9.0.0": {
"version": "9.0.0-beta.1",
"packages": {
"jest-preset-angular": {
"version": "8.0.0",
Expand Down
Expand Up @@ -5,7 +5,7 @@ import * as path from 'path';
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
import { serializeJson } from '@nrwl/workspace';

describe('Update 8.10.0', () => {
describe('Update 9.0.0', () => {
let initialTree: Tree;
let schematicRunner: SchematicTestRunner;

Expand Down Expand Up @@ -105,7 +105,7 @@ describe('Update 8.10.0', () => {

it('should update jest-preset-angular to 8.0.0', async () => {
const result = await schematicRunner
.runSchematicAsync('update-8.10.0', {}, initialTree)
.runSchematicAsync('update-9.0.0', {}, initialTree)
.toPromise();

const { devDependencies } = readJsonInTree(result, 'package.json');
Expand All @@ -114,7 +114,7 @@ describe('Update 8.10.0', () => {

it(`it should add '/build' into jest-preset-angular snapshotSerializers in any jest.config.js where it exists`, async () => {
const result = await schematicRunner
.runSchematicAsync('update-8.10.0', {}, initialTree)
.runSchematicAsync('update-9.0.0', {}, initialTree)
.toPromise();

const updateJestAngularOne = result.readContent(
Expand Down
Expand Up @@ -26,7 +26,7 @@ export default function update(): Rule {
displayInformation,
updatePackagesInPackageJson(
path.join(__dirname, '../../../', 'migrations.json'),
'8.10.0'
'9.0.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 a482722

Please sign in to comment.