Skip to content

Commit

Permalink
ci: add prerender e2e asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Jan 25, 2024
1 parent 7c176af commit daabe08
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: taiga-family/ci/actions/setup/[email protected]

- name: Building demo-app of git-branch without cache
run: npx nx build demo
run: npx nx prerender demo

- name: Upload cache / ${{ env.CACHE_DIST_KEY }}
uses: actions/cache/[email protected]
Expand Down
19 changes: 19 additions & 0 deletions projects/demo-playwright/tests/ssg.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {expect, test} from '@playwright/test';

test.describe('SSG', () => {
test('check responses', async ({page}) => {
const response = await page.goto('/');
const body = (await response?.text()) ?? '';
const prerendered = await page.evaluate(html => {
const parsed = new DOMParser().parseFromString(html, 'text/html');

return parsed.body.querySelector('app')?.children.length ?? 0;
}, body);

if (body.includes('This page was prerendered with Angular Universal')) {
expect(prerendered).toBeGreaterThan(0);
} else {
expect(prerendered).toBe(0);
}
});
});

0 comments on commit daabe08

Please sign in to comment.