@@ -3,44 +3,39 @@ import * as path from "path"
33import * as url from "url"
44import { expect , assert } from "chai"
55
6- let browserPage = null
7- let browser = null
6+ let browser , browserPage
87
98describe ( "Extension Integration Testing" , function ( ) {
10- this . timeout ( 25000 ) // wait for browser to open
11- before ( async ( ) => await setup ( ) )
9+ this . timeout ( 25000 )
1210
13- describe ( "App Page" , async function ( ) {
14- it ( "Check for a valid url" , async function ( ) {
15- const inputElement =
16- await browserPage . waitForSelector ( "#mainInstall" )
17- assert . ok ( inputElement )
18- await new Promise ( r => setTimeout ( r , 5000 ) )
19- expect ( await inputElement . evaluate ( el => el . href ) ) . match (
20- RegExp ( "^https:\\/\\/.{3}-data-\\d+\\.myket\\.ir" ) ,
21- )
11+ before ( async ( ) => {
12+ const __dirname = url . fileURLToPath ( new URL ( "." , import . meta. url ) )
13+ const extensionPath = path . join ( __dirname , ".." , "dist" )
14+ browser = await puppeteer . launch ( {
15+ executablePath : process . env . PUPPETEER_EXEC_PATH ,
16+ headless : false ,
17+ enableExtensions : [ extensionPath ] ,
18+ pipe : true ,
19+ args : [
20+ "--no-sandbox" ,
21+ "--disable-setuid-sandbox" ,
22+ "--font-render-hinting=none" ,
23+ ] ,
2224 } )
25+ browserPage = await browser . newPage ( )
26+ await browserPage . goto (
27+ "https://myket.ir/app/com.sibche.aspardproject.app" ,
28+ )
2329 } )
2430
25- after ( async ( ) => await browser . close ( ) )
26- } )
27-
28- async function setup ( ) {
29- const __dirname = url . fileURLToPath ( new URL ( "." , import . meta. url ) )
30- let extensionPath = path . join ( __dirname , ".." , "dist" )
31- console . log ( extensionPath )
32- browser = await puppeteer . launch ( {
33- executablePath : process . env . PUPPETEER_EXEC_PATH ,
34- headless : false ,
35- enableExtensions : [ extensionPath ] ,
36- pipe : true ,
37- args : [
38- "--no-sandbox" ,
39- "--disable-setuid-sandbox" ,
40- "--font-render-hinting=none" ,
41- ] ,
31+ it ( "Check for a valid url" , async function ( ) {
32+ const inputElement = await browserPage . waitForSelector ( "#mainInstall" )
33+ assert . ok ( inputElement )
34+ await new Promise ( r => setTimeout ( r , 5000 ) )
35+ expect ( await inputElement . evaluate ( el => el . href ) ) . match (
36+ / ^ h t t p s : \/ \/ .{ 3 } - d a t a - \d + \. m y k e t \. i r / ,
37+ )
4238 } )
4339
44- browserPage = await browser . newPage ( )
45- await browserPage . goto ( "https://myket.ir/app/com.sibche.aspardproject.app" )
46- }
40+ after ( async ( ) => await browser . close ( ) )
41+ } )
0 commit comments