jest-environment import { Page , Browser } from "puppeteer" ; import { CONNECT_DELAY , delay , assertJsonContentAreEquals , assertItems , pickRandomItem , } from "../utils" ; function pickRandomAction ( ) { return pickRandomItem ( [ "#set" , "#delete" ] ) ; } const TEST_URL = "http://localhost:3007/storage/map" ; declare const browserA ; declare const browserB ; describe ( "Storage - LiveMap" , ( ) => { let firstPage , secondPage ; beforeEach ( async ( ) => { firstPage = await browserA . newPage ( ) ; secondPage = await browserB . newPage ( ) ; await Promise . all ( [ firstPage . goto ( TEST_URL ) , secondPage . goto ( TEST_URL ) ] ) ; await delay ( CONNECT_DELAY ) ; } ) ; afterEach ( async ( ) => { await firstPage . close ( ) ; await secondPage . close ( ) ; } ) ; it ( "fuzzy" , async ( ) => { await firstPage . click ( "#clear" ) ; await delay ( 1000 ) ; await assertItems ( [ firstPage , secondPage ] , { } ) ; await assertJsonContentAreEquals ( firstPage , secondPage ) ; for ( let i = 0 ; i < 100 ; i ++ ) { firstPage . click ( pickRandomAction ( ) ) ; secondPage . click ( pickRandomAction ( ) ) ; await delay ( 50 ) ; } await delay ( 5000 ) ; await assertJsonContentAreEquals ( firstPage , secondPage ) ; await firstPage . click ( "#clear" ) ; await delay ( 1000 ) ; await assertItems ( [ firstPage , secondPage ] , { } ) ; } ) ; } ) ;