Skip to content

Commit 4b762cd

Browse files
committed
test: write pre-rendered univeral html file to test outputs dir
Write server side pre-rendered kitchen sync app to bazel TEST_UNDECLARED_OUTPUTS_DIR. Update the DEBUG guide information to retrieve the generated `index-prerendered.html`
1 parent 6e1f522 commit 4b762cd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/universal-app/DEBUG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ the file will be stored in the `bazel-out` folder.
66

77
You can retrieve the path to the file by either running:
88

9-
* `bazel test //src/universal-app:server_test --test_output=all`
10-
* `echo $(bazel info bazel-bin)/src/universal-app/index-prerendered.html`
9+
* `bazel run //src/universal-app:server_test --test_output=all`
10+
* `echo $(bazel info bazel-testlogs)/src/universal-app/server_test/test.outputs/index-prerendered.html`

src/universal-app/prerender.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'zone.js';
33

44
import {renderModuleFactory} from '@angular/platform-server';
55
import {readFileSync, writeFileSync} from 'fs';
6-
import {join} from 'path';
6+
import {dirname, join} from 'path';
77

88
import {KitchenSinkRootServerModuleNgFactory} from './kitchen-sink-root.ngfactory';
99

@@ -16,10 +16,11 @@ const indexHtmlPath = require.resolve('./index.html');
1616
const result = renderModuleFactory(
1717
KitchenSinkRootServerModuleNgFactory,
1818
{document: readFileSync(indexHtmlPath, 'utf-8')});
19+
const outDir = process.env.TEST_UNDECLARED_OUTPUTS_DIR as string;
1920

2021
result
2122
.then(content => {
22-
const filename = join(__dirname, 'index-prerendered.html');
23+
const filename = join(outDir, 'index-prerendered.html');
2324

2425
console.log('Inspect pre-rendered page here:');
2526
console.log(`file://${filename}`);

0 commit comments

Comments
 (0)