3

Following How to globally set the preserveWhitespaces option in Angular to false? I set my configuration to disable white space preservation globally but when I run my tests this is not honored.

How does one set this for tests. I tried manually configuring the tsconfig.spec.json but that had no positive effect.

amcdnl
  • 8,470
  • 12
  • 63
  • 99

1 Answers1

3

Sorry for the delay(seems I missed your comment on my previous answer)

Tests are runned with Jit compiler so setting options on tsconfig won't have any effect.

We can use configureCompiler method on TestBed. Since the signature of this method doesn't support preserveWhitespases option we have to cast options to any.

Here is how it could look like:

app.component.spec.ts

beforeEach(async(() => {
   TestBed.configureCompiler({ preserveWhitespaces: false } as any)
     .configureTestingModule({
       declarations: [
         AppComponent
       ],
     }).compileComponents();
}));
yurzui
  • 205,937
  • 32
  • 433
  • 399