counter.spec.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { setupPuppeteer, E2E_TIMEOUT } from 'test/helpers'
  2. describe('e2e/counter', () => {
  3. const { page, text, click, sleep } = setupPuppeteer()
  4. async function testCounter (url) {
  5. await page().goto(url)
  6. expect(await text('#app')).toContain('Clicked: 0 times')
  7. await click('button:nth-child(1)')
  8. expect(await text('#app')).toContain('Clicked: 1 times')
  9. await click('button:nth-child(2)')
  10. expect(await text('#app')).toContain('Clicked: 0 times')
  11. await click('button:nth-child(3)')
  12. expect(await text('#app')).toContain('Clicked: 0 times')
  13. await click('button:nth-child(1)')
  14. expect(await text('#app')).toContain('Clicked: 1 times')
  15. await click('button:nth-child(3)')
  16. expect(await text('#app')).toContain('Clicked: 2 times')
  17. await click('button:nth-child(4)')
  18. expect(await text('#app')).toContain('Clicked: 2 times')
  19. await sleep(1000)
  20. expect(await text('#app')).toContain('Clicked: 3 times')
  21. }
  22. test('classic', async () => {
  23. await testCounter('http://localhost:8080/classic/counter/')
  24. }, E2E_TIMEOUT)
  25. test('composition', async () => {
  26. await testCounter('http://localhost:8080/composition/counter/')
  27. }, E2E_TIMEOUT)
  28. })