@@ -1792,6 +1792,85 @@ moduleTypes.forEach(({
17921792 ] )
17931793 assert . match ( testOutput , / R e t r y i n g " o t h e r c o n t e x t f a i l s " t o d e t e c t f l a k e s b e c a u s e i t i s n e w / )
17941794 } )
1795+
1796+ it ( 'sets TEST_HAS_FAILED_ALL_RETRIES when all EFD attempts fail' , async ( ) => {
1797+ receiver . setSettings ( {
1798+ early_flake_detection : {
1799+ enabled : true ,
1800+ slow_test_retries : {
1801+ '5s' : NUM_RETRIES_EFD ,
1802+ } ,
1803+ } ,
1804+ known_tests_enabled : true ,
1805+ } )
1806+
1807+ receiver . setKnownTests ( {
1808+ cypress : {
1809+ 'cypress/e2e/spec.cy.js' : [
1810+ 'context passes' , // known test that passes
1811+ // 'other context fails' is new and will fail all attempts
1812+ ] ,
1813+ } ,
1814+ } )
1815+
1816+ const receiverPromise = receiver
1817+ . gatherPayloadsMaxTimeout ( ( { url } ) => url . endsWith ( '/api/v2/citestcycle' ) , payloads => {
1818+ const events = payloads . flatMap ( ( { payload } ) => payload . events )
1819+ const tests = events . filter ( event => event . type === 'test' ) . map ( event => event . content )
1820+
1821+ // 1 known test + 1 new test with retries: 1 + (1 + 3) = 5 tests
1822+ assert . strictEqual ( tests . length , 5 )
1823+
1824+ const newTests = tests . filter ( test => test . meta [ TEST_IS_NEW ] === 'true' )
1825+ assert . strictEqual ( newTests . length , NUM_RETRIES_EFD + 1 )
1826+
1827+ // Check that TEST_HAS_FAILED_ALL_RETRIES is only set on the last attempt
1828+ const testsWithFailedAllRetries = newTests . filter (
1829+ test => test . meta [ TEST_HAS_FAILED_ALL_RETRIES ] === 'true'
1830+ )
1831+ assert . strictEqual (
1832+ testsWithFailedAllRetries . length ,
1833+ 1 ,
1834+ 'Exactly one test should have TEST_HAS_FAILED_ALL_RETRIES set'
1835+ )
1836+
1837+ // Check that it's set on the last attempt
1838+ const lastAttempt = newTests [ newTests . length - 1 ]
1839+ assert . strictEqual ( lastAttempt . meta [ TEST_HAS_FAILED_ALL_RETRIES ] , 'true' )
1840+
1841+ // Check that earlier attempts don't have the flag
1842+ for ( let i = 0 ; i < newTests . length - 1 ; i ++ ) {
1843+ assert . ok ( ! ( TEST_HAS_FAILED_ALL_RETRIES in newTests [ i ] . meta ) )
1844+ }
1845+
1846+ const testSession = events . find ( event => event . type === 'test_session_end' ) . content
1847+ assert . strictEqual ( testSession . meta [ TEST_EARLY_FLAKE_ENABLED ] , 'true' )
1848+ } , 25000 )
1849+
1850+ const {
1851+ NODE_OPTIONS , // NODE_OPTIONS dd-trace config does not work with cypress
1852+ ...restEnvVars
1853+ } = getCiVisEvpProxyConfig ( receiver . port )
1854+
1855+ const specToRun = 'cypress/e2e/spec.cy.js'
1856+
1857+ childProcess = exec (
1858+ version === 'latest' ? testCommand : `${ testCommand } --spec ${ specToRun } ` ,
1859+ {
1860+ cwd,
1861+ env : {
1862+ ...restEnvVars ,
1863+ CYPRESS_BASE_URL : `http://localhost:${ webAppPort } ` ,
1864+ SPEC_PATTERN : specToRun ,
1865+ } ,
1866+ }
1867+ )
1868+
1869+ await Promise . all ( [
1870+ once ( childProcess , 'exit' ) ,
1871+ receiverPromise ,
1872+ ] )
1873+ } )
17951874 } )
17961875
17971876 context ( 'flaky test retries' , ( ) => {
0 commit comments