Updated to Angular v15. When running ng test I am getting the following error:
⠋ Generating browser application bundles (phase: setup)...node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
AssertionError [ERR_ASSERTION]: Compilation cannot be undefined.
at webpackOptions.entry (D:\wqems\WqEMS-portal\wqems-portal\node_modules\@angular-devkit\build-angular\src\webpack\plugins\styles-webpack-plugin.js:58:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: undefined,
expected: true,
operator: '=='
}
Node.js v18.12.1
Any help on what is going wrong would be highly appreciated.
The error comes from the fact that a style file cannot be found during testing. In the angular.json file under "test.styles" the path to the *.(s)css must be adjusted so that they are valid.
e.g.:
"styles": ["src/styles/global.css"]
to
"styles": ["src/styles/global.scss"]
I had this error, too, after upgrading Angular 14 -> 15, but only in one of my four subprojects.
It turned out this single subproject did not have any karma tests (anymore), so the findTests() method of @angular-devkit did not find any matches to **/*.spec.ts and threw this misleading error.
In my case, I fixed it by simply adding a dummy test case, as I wanted to keep the working test chain for later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With