import { expect , skipIf } from '@loopback/testlab' ; import fs from 'fs' ; import { Suite } from 'mocha' ; import path from 'path' ; import puppeteer , { Browser } from 'puppeteer' ; import url from 'url' ; import { generateBundle } from './test-helper' ; skipIf < [ ( this : Suite ) => void ] , void > ( process . platform === 'win32' , describe , 'bundle-web.js' , ( ) => { before ( 'generate bundle-web.js' , async function ( this ) { this . timeout ( 30000 ) ; await generateBundle ( 'web' ) ; expect ( fs . existsSync ( path . join ( __dirname , '../../bundle-web.js' ) ) ) . to . be . true ( ) ; } ) ; let browser ; let html ; before ( async function ( this ) { this . timeout ( 15000 ) ; browser = await puppeteer . launch ( ) ; const page = await browser . newPage ( ) ; await page . goto ( url . pathToFileURL ( path . join ( __dirname , '../../../index.html' ) ) . toString ( ) , { waitUntil : 'networkidle2' } ) ; html = await page . content ( ) ; await browser . close ( ) ; } ) ; it ( 'should see the page with greetings' , ( ) => { let body = html ; body = body . replace ( /\[[^\[\]]+\] /g , '' ) ; expect ( body ) . to . match ( /<li>\(en\) Hello, Jane!<\/li>/ ) ; expect ( body ) . to . match ( /<li>Hello, John!<\/li>/ ) ; expect ( body ) . to . match ( /<li>\(zh\) 你好，John！<\/li>/ ) ; expect ( body ) . to . match ( /<li>\(en\) Hello, Jane!<\/li>/ ) ; } ) ; } ) ;