@@ -1562,12 +1562,14 @@ describe('e2e', function () {
1562
1562
expect ( await shell . executeLine ( 'print(123 + 456)' ) ) . to . include ( '579' ) ;
1563
1563
expect ( shell . logId ) . not . equal ( null ) ;
1564
1564
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
+ } ) ;
1571
1573
} ) ;
1572
1574
1573
1575
describe ( 'with custom log location' , function ( ) {
@@ -1653,8 +1655,6 @@ describe('e2e', function () {
1653
1655
1654
1656
expect ( shell . logId ) . equals ( oldLogId ) ;
1655
1657
1656
- const currentLogEntries = await readLogFile ( ) ;
1657
-
1658
1658
try {
1659
1659
await readLogFile ( customLogDir . path ) ;
1660
1660
expect . fail ( 'expected to throw' ) ;
@@ -1663,14 +1663,19 @@ describe('e2e', function () {
1663
1663
'no such file or directory'
1664
1664
) ;
1665
1665
}
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
+ } ) ;
1674
1679
} ) ;
1675
1680
} ) ;
1676
1681
@@ -1962,37 +1967,43 @@ describe('e2e', function () {
1962
1967
1963
1968
it ( 'creates a log file that keeps track of session events' , async function ( ) {
1964
1969
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
+ } ) ;
1971
1978
} ) ;
1972
1979
1973
1980
it ( 'does not write to the log after disableLogging is set to true' , async function ( ) {
1974
1981
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
+ } ) ;
1981
1990
1982
1991
await shell . executeLine ( `config.set("disableLogging", true)` ) ;
1983
1992
expect ( await shell . executeLine ( 'print(579 - 123)' ) ) . to . include ( '456' ) ;
1984
1993
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
+ } ) ;
1996
2007
} ) ;
1997
2008
1998
2009
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 () {
2008
2019
await shell . executeLine ( `config.set("disableLogging", true)` ) ;
2009
2020
expect ( await shell . executeLine ( 'print(123 + 456)' ) ) . to . include ( '579' ) ;
2010
2021
2011
- log = await readLogFile ( ) ;
2012
- const oldLogId = shell . logId ;
2013
- expect ( oldLogId ) . not . null ;
2022
+ let oldLogId : string | null = null ;
2014
2023
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
+ } ) ;
2020
2035
2021
2036
await shell . executeLine ( `config.set("disableLogging", false)` ) ;
2022
2037
0 commit comments