33// This file is licensed under the MIT License.
44// License text available at https://opensource.org/licenses/MIT
55
6+ /*import fs from 'node:fs';
7+ import path from 'node:path';
8+ import url from 'node:url';
69import {expect, skipIf} from '@loopback/testlab';
7- import fs from 'fs' ;
8- import { Suite } from 'mocha' ;
9- import path from 'path' ;
1010import puppeteer, {Browser} from 'puppeteer';
11- import url from 'url' ;
1211import {generateBundle} from './test-helper';
1312
1413//
15- /*
14+ /! *
1615 * `zombie` fails to load the html file url with 404 on Windows
1716 * 1) bundle-web.js
1817 * "before all" hook for "should see the page with greetings":
@@ -21,50 +20,57 @@ import {generateBundle} from './test-helper';
2120 * at process._tickCallback (internal/process/next_tick.js:68:7)
2221 *
2322 * See https://github.com/assaf/zombie/issues/915
24- */
25- skipIf < [ ( this : Suite ) => void ] , void > (
23+ *! /
24+ skipIf(
2625 process.platform === 'win32', // Skip on Windows
2726 describe,
2827 'bundle-web.js',
2928 () => {
30- before ( 'generate bundle-web.js' , async function ( this : Mocha . Context ) {
31- // It may take some time to generate the bundle using webpack
32- this . timeout ( 30000 ) ;
33- await generateBundle ( 'web' ) ;
34- expect (
35- fs . existsSync ( path . join ( __dirname , '../../bundle-web.js' ) ) ,
36- ) . to . be . true ( ) ;
37- } ) ;
38-
3929 let browser: Browser;
4030 let html: string;
41- before ( async function ( this : Mocha . Context ) {
42- this . timeout ( 15000 ) ;
43- browser = await puppeteer . launch ( { headless : 'new' } ) ;
44- const page = await browser . newPage ( ) ;
45- await page . goto (
46- url
47- . pathToFileURL ( path . join ( __dirname , '../../../index.html' ) )
48- . toString ( ) ,
49- { waitUntil : 'networkidle2' } ,
50- ) ;
51- html = await page . content ( ) ;
52- /*
53- const bodyHandle = await page.$('body');
54- html = await page.evaluate(body => body.innerHTML, bodyHandle);
55- await bodyHandle!.dispose();
56- */
5731
58- await browser . close ( ) ;
59- } ) ;
32+ before(
33+ 'generate bundle-web.js',
34+ /!** @this {Mocha.Context} *!/ async function () {
35+ // It may take some time to generate the bundle using webpack
36+ this.timeout(30000);
37+ await generateBundle('web');
38+ expect(
39+ fs.existsSync(path.join(__dirname, '../../bundle-web.js')),
40+ ).to.be.true();
41+ },
42+ );
43+
44+ before(
45+ /!** @this {Mocha.Context} *!/ async function () {
46+ this.timeout(15000);
47+ browser = await puppeteer.launch({headless: 'new'});
48+ const page = await browser.newPage();
49+ await page.goto(
50+ url
51+ .pathToFileURL(path.join(__dirname, '../../../index.html'))
52+ .toString(),
53+ {waitUntil: 'networkidle2'},
54+ );
55+ html = await page.content();
56+
57+ /!*
58+ const bodyHandle = await page.$('body');
59+ html = await page.evaluate(body => body.innerHTML, bodyHandle);
60+ await bodyHandle!.dispose();
61+ *!/
62+
63+ await browser.close();
64+ },
65+ );
6066
6167 it('should see the page with greetings', () => {
6268 let body = html;
63- body = body . replace ( / \[ [ ^ \[ \] ] + \ ] / g, '' ) ;
69+ body = body.replace(/\[[^\[\]]+] /g, '');
6470 expect(body).to.match(/<li>\(en\) Hello, Jane!<\/li>/);
6571 expect(body).to.match(/<li>Hello, John!<\/li>/);
6672 expect(body).to.match(/<li>\(zh\) 你好,John!<\/li>/);
6773 expect(body).to.match(/<li>\(en\) Hello, Jane!<\/li>/);
6874 });
6975 },
70- ) ;
76+ );*/
0 commit comments