home.test.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. describe('render correct content', async () => {
  2. beforeAll(async () => {
  3. await goto('/home')
  4. })
  5. test('main content', async () => {
  6. const h1Locator = page.locator('.VPContent h1')
  7. const h2Locator = page.locator('.VPContent h2')
  8. const pLocator = page.locator('.VPContent p')
  9. const [h1Contents, h2Contents, pContents] = await Promise.all([
  10. h1Locator.allTextContents(),
  11. h2Locator.allTextContents(),
  12. pLocator.allTextContents()
  13. ])
  14. expect(h1Contents).toEqual(['Lorem Ipsum \u200b'])
  15. expect(h2Contents.map((s) => s.trim())).toEqual([
  16. 'What is Lorem Ipsum? \u200b',
  17. 'Where does it come from? \u200b',
  18. 'Why do we use it? \u200b',
  19. 'Where can I get some? \u200b'
  20. ])
  21. expect(pContents).toMatchSnapshot()
  22. })
  23. test('outline', async () => {
  24. const outlineLinksLocator = page.locator(
  25. '.VPDocAsideOutline .root .outline-link'
  26. )
  27. const outlineLinksCount = await outlineLinksLocator.count()
  28. expect(outlineLinksCount).toEqual(4)
  29. })
  30. })