test: use polling for more stable markdown e2e tests

close #1908
This commit is contained in:
Evan You
2020-08-20 10:51:25 -04:00
parent d4cc7b2496
commit a74f8d7891
2 changed files with 25 additions and 3 deletions

View File

@@ -1,5 +1,9 @@
import path from 'path'
import { setupPuppeteer, E2E_TIMEOUT } from '../../__tests__/e2eUtils'
import {
setupPuppeteer,
expectByPolling,
E2E_TIMEOUT
} from '../../__tests__/e2eUtils'
describe('e2e: markdown', () => {
const { page, isVisible, value, html } = setupPuppeteer()
@@ -18,8 +22,8 @@ describe('e2e: markdown', () => {
await page().type('textarea', '\n## foo\n\n- bar\n- baz')
// assert the output is not updated yet because of debounce
expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
await page().waitFor(200)
expect(await html('#editor div')).toBe(
await expectByPolling(
() => html('#editor div'),
'<h1 id="hello">hello</h1>\n' +
'<h2 id="foo">foo</h2>\n' +
'<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n'