convert angular 7 project into angular universal while running "ng test" command giving error as "Incomplete: No specs found, , randomized with seed 48751
".
Tried different ways mention over stackoverflow but nothing work for me.
ERROR in ./src/polyfills.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: ../src/polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (../node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/angular_compiler_plugin.ts:1024:15)
at plugin.done.then (../node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/loader.ts:49:29)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ multi ./src/polyfills.ts ./node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/jit-polyfills.js polyfills[0]
Expected output to be ng test command run properly without giving any issue so that my unit test-cases gonna execute.
Finally after lot of experiments got the solution. just add
`"include": [
"**/*.spec.ts",
"**/*.d.ts",
"**/*.ts"
]`
in "tsconfig.spec.json" Hope this helpful :)
This error may happen if there is some compile error in some of the unit test files, if this happens, the compilation error will be seen in the command prompt where "ng test" has been run.
For example, the built-in "app.component.spec.ts" contains a test expecting the title variable to have the App title. If you have deleted this variable from "app.component.ts" the fact that the test still contains it will not cause the build to fail but an error will happing when running the tests.
You just have to have the correct paths.
I got a lot of errors with the following in the tsconfig.spec.json file:
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
Then I got everything right after I changed the paths to the following:
"files": [
"src/test.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
For me, it was actually a compile error that was causing it. I was also receiving:
error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
Fixed it by adding "types": ["node"]
and "typeRoots": ["node_modules/@types"]
to the compilerOptions in the tsconfig.spec.json
, so that it looks something like this in the end:
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine",
"node"
],
"typeRoots": ["node_modules/@types"]
},
"files": [
"src/test.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}
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