-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(module-doc): add basic test case for module doc (#3998)
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
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
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'); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
"demo": ["."] | ||
} | ||
}, | ||
"include": ["src"] | ||
"include": ["src", "tests"] | ||
} |