@@ -1562,12 +1562,14 @@ describe('e2e', function () {
15621562 expect ( await shell . executeLine ( 'print(123 + 456)' ) ) . to . include ( '579' ) ;
15631563 expect ( shell . logId ) . not . equal ( null ) ;
15641564
1565- const log = await readLogFile ( ) ;
1566- expect (
1567- log . filter (
1568- ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
1569- )
1570- ) . to . have . lengthOf ( 1 ) ;
1565+ await eventually ( async ( ) => {
1566+ const log = await readLogFile ( ) ;
1567+ expect (
1568+ log . filter (
1569+ ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
1570+ )
1571+ ) . to . have . lengthOf ( 1 ) ;
1572+ } ) ;
15711573 } ) ;
15721574
15731575 describe ( 'with custom log location' , function ( ) {
@@ -1653,8 +1655,6 @@ describe('e2e', function () {
16531655
16541656 expect ( shell . logId ) . equals ( oldLogId ) ;
16551657
1656- const currentLogEntries = await readLogFile ( ) ;
1657-
16581658 try {
16591659 await readLogFile ( customLogDir . path ) ;
16601660 expect . fail ( 'expected to throw' ) ;
@@ -1663,14 +1663,19 @@ describe('e2e', function () {
16631663 'no such file or directory'
16641664 ) ;
16651665 }
1666- expect (
1667- currentLogEntries . some (
1668- ( log ) => log . attr ?. input === 'config.get("logLocation")'
1669- )
1670- ) . is . true ;
1671- expect ( currentLogEntries . length ) . is . greaterThanOrEqual (
1672- oldLogEntries . length
1673- ) ;
1666+
1667+ await eventually ( async ( ) => {
1668+ const currentLogEntries = await readLogFile ( ) ;
1669+
1670+ expect (
1671+ currentLogEntries . some (
1672+ ( log ) => log . attr ?. input === 'config.get("logLocation")'
1673+ )
1674+ ) . is . true ;
1675+ expect ( currentLogEntries . length ) . is . greaterThanOrEqual (
1676+ oldLogEntries . length
1677+ ) ;
1678+ } ) ;
16741679 } ) ;
16751680 } ) ;
16761681
@@ -1962,37 +1967,43 @@ describe('e2e', function () {
19621967
19631968 it ( 'creates a log file that keeps track of session events' , async function ( ) {
19641969 expect ( await shell . executeLine ( 'print(123 + 456)' ) ) . to . include ( '579' ) ;
1965- const log = await readLogFile ( ) ;
1966- expect (
1967- log . filter (
1968- ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
1969- )
1970- ) . to . have . lengthOf ( 1 ) ;
1970+ await eventually ( async ( ) => {
1971+ const log = await readLogFile ( ) ;
1972+ expect (
1973+ log . filter (
1974+ ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
1975+ )
1976+ ) . to . have . lengthOf ( 1 ) ;
1977+ } ) ;
19711978 } ) ;
19721979
19731980 it ( 'does not write to the log after disableLogging is set to true' , async function ( ) {
19741981 expect ( await shell . executeLine ( 'print(123 + 456)' ) ) . to . include ( '579' ) ;
1975- const log = await readLogFile ( ) ;
1976- expect (
1977- log . filter (
1978- ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
1979- )
1980- ) . to . have . lengthOf ( 1 ) ;
1982+ await eventually ( async ( ) => {
1983+ const log = await readLogFile ( ) ;
1984+ expect (
1985+ log . filter (
1986+ ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
1987+ )
1988+ ) . to . have . lengthOf ( 1 ) ;
1989+ } ) ;
19811990
19821991 await shell . executeLine ( `config.set("disableLogging", true)` ) ;
19831992 expect ( await shell . executeLine ( 'print(579 - 123)' ) ) . to . include ( '456' ) ;
19841993
1985- const logAfterDisabling = await readLogFile ( ) ;
1986- expect (
1987- logAfterDisabling . filter (
1988- ( logEntry ) => logEntry . attr ?. input === 'print(579 - 123)'
1989- )
1990- ) . to . have . lengthOf ( 0 ) ;
1991- expect (
1992- logAfterDisabling . filter (
1993- ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
1994- )
1995- ) . to . have . lengthOf ( 1 ) ;
1994+ await eventually ( async ( ) => {
1995+ const logAfterDisabling = await readLogFile ( ) ;
1996+ expect (
1997+ logAfterDisabling . filter (
1998+ ( logEntry ) => logEntry . attr ?. input === 'print(579 - 123)'
1999+ )
2000+ ) . to . have . lengthOf ( 0 ) ;
2001+ expect (
2002+ logAfterDisabling . filter (
2003+ ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
2004+ )
2005+ ) . to . have . lengthOf ( 1 ) ;
2006+ } ) ;
19962007 } ) ;
19972008
19982009 it ( 'starts writing to the same log from the point where disableLogging is set to false' , async function ( ) {
@@ -2008,15 +2019,19 @@ describe('e2e', function () {
20082019 await shell . executeLine ( `config.set("disableLogging", true)` ) ;
20092020 expect ( await shell . executeLine ( 'print(123 + 456)' ) ) . to . include ( '579' ) ;
20102021
2011- log = await readLogFile ( ) ;
2012- const oldLogId = shell . logId ;
2013- expect ( oldLogId ) . not . null ;
2022+ let oldLogId : string | null = null ;
20142023
2015- expect (
2016- log . filter (
2017- ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
2018- )
2019- ) . to . have . lengthOf ( 0 ) ;
2024+ await eventually ( async ( ) => {
2025+ log = await readLogFile ( ) ;
2026+ oldLogId = shell . logId ;
2027+ expect ( oldLogId ) . not . null ;
2028+
2029+ expect (
2030+ log . filter (
2031+ ( logEntry ) => logEntry . attr ?. input === 'print(123 + 456)'
2032+ )
2033+ ) . to . have . lengthOf ( 0 ) ;
2034+ } ) ;
20202035
20212036 await shell . executeLine ( `config.set("disableLogging", false)` ) ;
20222037
0 commit comments