| 10 | const {logPromise} = require('../utils'); |
| 11 | |
| 12 | const validate = async () => { |
| 13 | const browser = await puppeteer.launch(); |
| 14 | const page = await browser.newPage(); |
| 15 | |
| 16 | await page.goto('http://localhost:9000/fixtures/packaging'); |
| 17 | |
| 18 | try { |
| 19 | return await page.evaluate(() => { |
| 20 | const iframes = document.querySelectorAll('iframe'); |
| 21 | |
| 22 | if (iframes.length === 0) { |
| 23 | return 'No iframes were found.'; |
| 24 | } |
| 25 | |
| 26 | for (let i = 0; i < iframes.length; i++) { |
| 27 | const iframe = iframes[i]; |
| 28 | // Don't include the <script> Babel tag |
| 29 | const container = |
| 30 | iframe.contentDocument.body.getElementsByTagName('div')[0]; |
| 31 | if (container.textContent !== 'Hello World!') { |
| 32 | return `Unexpected fixture content, "${container.textContent}"`; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return null; |
| 37 | }); |
| 38 | } finally { |
| 39 | await browser.close(); |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | const run = async ({cwd}) => { |
| 44 | await logPromise( |