ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 1 | import { TestBed } from '@angular/core/testing' |
| 2 | |
| 3 | type CompilerOptions = Partial<{ |
| 4 | providers: any[] |
| 5 | useJit: boolean |
| 6 | preserveWhitespaces: boolean |
| 7 | }> |
| 8 | export type ConfigureFn = (testBed: typeof TestBed) => void |
| 9 | |
| 10 | export const configureTests = (configure: ConfigureFn, compilerOptions: CompilerOptions = {}) => { |
| 11 | const compilerConfig: CompilerOptions = { |
| 12 | preserveWhitespaces: false, |
| 13 | ...compilerOptions, |
| 14 | }; |
| 15 | |
| 16 | const configuredTestBed = TestBed.configureCompiler(compilerConfig); |
| 17 | |
| 18 | configure(configuredTestBed); |
| 19 | |
| 20 | return configuredTestBed.compileComponents().then(() => configuredTestBed) |
| 21 | }; |