I m trying to compile in production my angular application and I m receiving this error:
Cannot determine the module for class TranslateMockPipe in /src/testing/translate.service.spec.ts! Add TranslateMockPipe to the NgModule to fix it.
this TranslateMockPipe
class is a common class that I declared and I m using it in all my test files in order to avoid repeating the same line of code in all the test cases
the code of the class:
@Pipe({ name: "translate" })
class TranslateMockPipe {
transform = (ss) => ss
}
I m using it in my test like this:
TestBed.configureTestingModule({
declarations: [
DemoComponent,
TranslateMockPipe
]
})
If I run the project everything goes well, and my test pass without issues but fail when I try to compile for production
How I can ignore this kind of fake classes for production build?
You can read it up on this ticket but the simplest ways should be:
add a path where you have your testing utilites e.g. "./app/shared/tests/" and in your tsconfig.json add:
"exclude": [
"./app/shared/tests/*.ts"
]
or
If you are using Ionic Framework with Angular, you need to update the exclude
section in tsconfig.app.json
so it lists the files that appear in the error message (or most likely, all similarly named files).
Error:
Cannot determine the module for class TranslateMockPipe in /src/testing/translate.service.spec.ts! Add TranslateMockPipe to the NgModule to fix it.
tsconfig.app.json
...
"exclude": [
"src/testing/*.service.spec.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