Skip to content

Commit

Permalink
fix(angular): karma migrator fixes (#9063)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Feb 22, 2022
1 parent b14e850 commit 5d9176e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
20 changes: 20 additions & 0 deletions packages/angular/migrations.json
Expand Up @@ -150,6 +150,12 @@
"version": "13.8.1",
"description": "Angular doesn't attach styles.js to index.html with type=module in dev mode, meaning an error is written to the console. Cypress falls over on this error. Add logic to Cypress e2e projects to ignore this error.",
"factory": "./src/migrations/update-13-8-1/add-cypress-mfe-workaround"
},
"migrate-karma-config": {
"cli": "nx",
"version": "13.8.4",
"description": "Karma coverage is broken since Angular 13 upgarde and the karma config is severely out of date. Bring it up to date fixing the coverage issue.",
"factory": "./src/migrations/update-13-8-4/migrate-karma-conf"
}
},
"packageJsonUpdates": {
Expand Down Expand Up @@ -1355,6 +1361,20 @@
"alwaysAddToPackageJson": false
}
}
},
"13.8.4": {
"version": "13.8.4-beta.0",
"packages": {
"karma": { "version": "~6.3.0", "alwaysAddToPackageJson": false },
"karma-jasmine-html-reporter": {
"version": "~1.7.0",
"alwaysAddToPackageJson": false
},
"jasmine-core": {
"version": "~3.10.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
Expand Up @@ -5,10 +5,7 @@ exports[`Migrate Karma Config should successfully migrate outdate karma setup 1`
\\"name\\": \\"test-name\\",
\\"dependencies\\": {},
\\"devDependencies\\": {
\\"jasmine-core\\": \\"~3.10.0\\",
\\"karma\\": \\"~6.3.0\\",
\\"karma-coverage\\": \\"~2.2.0\\",
\\"karma-jasmine-html-reporter\\": \\"~1.7.0\\"
\\"karma-coverage\\": \\"~2.2.0\\"
}
}
"
Expand Down Expand Up @@ -39,7 +36,7 @@ exports[`Migrate Karma Config should successfully migrate outdate karma setup 2`
dir: join(__dirname, './coverage'),
subdir: '.',
reporters: [{ type: 'html' }, { type: 'text-summary' }],
fixWebpackSourcePaths: true,
},
reporters: ['progress', 'kjhtml'],
port: 9876,
Expand Down
Expand Up @@ -36,21 +36,19 @@ export default async function (tree: Tree) {
.replace(/coverageIstanbulReporter/g, 'coverageReporter')
.replace(/karma-coverage-istanbul-reporter/, 'karma-coverage')
.replace(
/reports: \['html', 'lcovonly'\]/,
/reports: \[(.+)\]/,
`subdir: '.',\nreporters: [{ type: 'html' }, { type: 'text-summary' }]`
)
.replace(/'\.\.\/\.\.\/coverage'/, `'./coverage'`);
.replace(/'\.\.\/\.\.\/coverage'/, `'./coverage'`)
.replace(/fixWebpackSourcePaths: true,/, '');

tree.write(pathToRootKarmaConf, updatedKarmaContents);

const installPackages = addDependenciesToPackageJson(
tree,
{},
{
karma: '~6.3.0',
'karma-coverage': '~2.2.0',
'karma-jasmine-html-reporter': '~1.7.0',
'jasmine-core': '~3.10.0',
}
);

Expand Down

0 comments on commit 5d9176e

Please sign in to comment.