Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): karma migrator fixes #9063

Merged
merged 1 commit into from Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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