@@ -12,30 +12,55 @@ const codecept_dir = path.join(__dirname, '/../data/internal-api-tsx-cjs')
1212const codecept_run = `${ runner } run --config ${ codecept_dir } /codecept.conf.ts`
1313
1414// Regression test for https://github.com/codeceptjs/CodeceptJS/issues/5635
15- // The internal API (config/container/recorder/event/store) must resolve to the live
16- // singletons when imported from a test through a CommonJS loader (tsx/cjs), not a second ,
17- // disconnected copy. Drives a real tsx/cjs project and asserts each one is the live instance .
15+ // The internal API (config/container/recorder/event/store, and the effects that delegate to them)
16+ // must resolve to the live singletons when imported from a test through a CommonJS loader (tsx/cjs),
17+ // not a second, disconnected copy. Drives a real tsx/cjs project once and asserts on its output .
1818describe ( 'CodeceptJS internal API under tsx/cjs' , function ( ) {
1919 this . timeout ( 40000 )
2020
21- it ( 'resolves config/container/recorder/event/store to the live singletons from a test' , done => {
22- exec ( `${ codecept_run } ` , { timeout : 30000 } , ( err , stdout ) => {
23- stdout . should . include ( '1 passed' )
24- // config (#5635): the real config the runner loaded, not an empty {}
25- stdout . should . include ( 'API_CONFIG name=internal-api-tsx-cjs-test' )
26- stdout . should . include ( 'API_CONFIG marker=config-marker-123' )
27- // container: the live helpers map populated by the runner
28- stdout . should . include ( 'API_CONTAINER helper=object' )
29- // store: initialized by the runner
30- stdout . should . include ( 'API_STORE hasDir=true' )
31- // recorder: started by the runner for this test
32- stdout . should . include ( 'API_RECORDER running=true' )
33- // event: the live dispatcher the framework subscribes to
34- stdout . should . include ( 'API_EVENT live=true' )
35- // helper (ESM realm) reads the same live config
36- stdout . should . include ( 'API_HELPER marker=config-marker-123' )
37- chai . expect ( err ) . to . be . null
21+ let stdout = ''
22+ let runErr = null
23+
24+ // Run the fixture once; the `timeout` kills the child if a regression makes retryTo() hang forever
25+ // (its manual promise never resolves on a disconnected recorder), so a broken fix fails on the
26+ // missing markers instead of hanging the whole suite.
27+ before ( done => {
28+ exec ( `${ codecept_run } ` , { timeout : 30000 } , ( err , out ) => {
29+ runErr = err
30+ stdout = out
3831 done ( )
3932 } )
4033 } )
34+
35+ it ( 'resolves config/container/recorder/event/store to the live singletons from a test' , ( ) => {
36+ stdout . should . include ( '5 passed' )
37+ // config (#5635): the real config the runner loaded, not an empty {}
38+ stdout . should . include ( 'API_CONFIG name=internal-api-tsx-cjs-test' )
39+ stdout . should . include ( 'API_CONFIG marker=config-marker-123' )
40+ // container: the live helpers map populated by the runner
41+ stdout . should . include ( 'API_CONTAINER helper=object' )
42+ // store: initialized by the runner
43+ stdout . should . include ( 'API_STORE hasDir=true' )
44+ // recorder: started by the runner for this test
45+ stdout . should . include ( 'API_RECORDER running=true' )
46+ // event: the live dispatcher the framework subscribes to
47+ stdout . should . include ( 'API_EVENT live=true' )
48+ // helper (ESM realm) reads the same live config
49+ stdout . should . include ( 'API_HELPER marker=config-marker-123' )
50+ chai . expect ( runErr ) . to . be . null
51+ } )
52+
53+ it ( 'runs within/tryTo/hopeThat/retryTo imported through the CJS loader' , ( ) => {
54+ // tryTo ran its callback and resolved to false (a failed try), instead of returning
55+ // undefined from a disconnected, never-started recorder
56+ stdout . should . include ( 'EFFECTS_TRYTO result=false' )
57+ // within() applied its context so the inner step saw _withinBegin
58+ stdout . should . include ( 'EFFECTS_CLICK withinActive=true' )
59+ // hopeThat() ran its callback and resolved to true
60+ stdout . should . include ( 'EFFECTS_PASS ran' )
61+ stdout . should . include ( 'EFFECTS_HOPETHAT result=true' )
62+ // retryTo() retried the flaky callback until it passed (and did not hang)
63+ stdout . should . include ( 'EFFECTS_FLAKY try=2' )
64+ stdout . should . include ( 'EFFECTS_RETRY done' )
65+ } )
4166} )
0 commit comments