Created
October 8, 2017 10:26
-
-
Save Toxicable/b61b0742e061c5e3f2e569206c0876ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function validate(module: any, bootstrapComponent: any, selector = 'app-root', timeout = 5000) { | |
@NgModule({ | |
imports: [ | |
BrowserModule.withServerTransition({ appId: selector }), | |
module | |
], | |
declarations: [bootstrapComponent], | |
bootstrap: [bootstrapComponent], | |
}) | |
class AppModule { } | |
@NgModule({ | |
imports: [ | |
ServerModule, | |
AppModule, | |
], | |
bootstrap: [bootstrapComponent], | |
}) | |
class AppServerModule { } | |
const document = `<${selector}></${selector}>`; | |
let rendered = false; | |
setTimeout(() => { | |
if (!rendered) { | |
throw new Error('Module did not render in time. Check that all async operations have been cleaned up'); | |
} | |
}, timeout); | |
return renderModule(AppServerModule, { | |
document, | |
}).then(html => { | |
rendered = true; | |
return html; | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment