Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(module-doc): add basic test case for module doc #3998

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions tests/integration/module-doc/tests/basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { join } from 'path';
import type { Page, Browser } from 'puppeteer';
import puppeteer from 'puppeteer';
import {
launchApp,
getPort,
killApp,
launchOptions,
} from '../../../utils/modernTestUtils';

describe('Check basic render in development', () => {
let app: any;
let page: Page;
let browser: Browser;
let appPort: number;
beforeAll(async () => {
const appDir = join(__dirname, '..');
appPort = await getPort();
app = await launchApp(appDir, appPort);
browser = await puppeteer.launch(launchOptions as any);
page = await browser.newPage();
});

afterAll(async () => {
if (app) {
await killApp(app);
}
if (page) {
await page.close();
}
if (browser) {
browser.close();
}
});

it('Index page', async () => {
await page.goto(`http://localhost:${appPort}/en/`, {
waitUntil: ['networkidle0'],
});
const h1 = await page.$('h1');
const text = await page.evaluate(h1 => h1?.textContent, h1);
expect(text).toContain('Components Overview');
// expect the .header-anchor to be rendered and take the correct href
const headerAnchor = await page.$('.header-anchor');
const href = await page.evaluate(
headerAnchor => headerAnchor?.getAttribute('href'),
headerAnchor,
);
expect(href).toBe('#components-overview');
});

it('404 page', async () => {
await page.goto(`http://localhost:${appPort}/404`, {
waitUntil: ['networkidle0'],
});
// find the 404 text in the page
const text = await page.evaluate(() => document.body.textContent);
expect(text).toContain('404');
});
});
2 changes: 1 addition & 1 deletion tests/integration/module-doc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"demo": ["."]
}
},
"include": ["src"]
"include": ["src", "tests"]
}
Loading