@@ -132,6 +132,84 @@ describe('Test discovery', () => {
132132 } ) ;
133133} ) ;
134134
135+ describe ( '--from-file comment filtering' , ( ) => {
136+ const currentCwd = process . cwd ( ) ;
137+ let tempDir : string ;
138+
139+ beforeEach ( ( ) => {
140+ tempDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'integ-runner-test-' ) ) ;
141+ process . chdir ( tempDir ) ;
142+ } ) ;
143+
144+ afterEach ( ( ) => {
145+ process . chdir ( currentCwd ) ;
146+ fs . rmSync ( tempDir , { recursive : true , force : true } ) ;
147+ } ) ;
148+
149+ test ( 'filters out comment lines starting with #' , ( ) => {
150+ // Create temp file with mix of comments and test names
151+ const testFile = path . join ( tempDir , 'tests.txt' ) ;
152+ fs . writeFileSync ( testFile , [
153+ '# This is a comment' ,
154+ 'test1.js' ,
155+ '# Another comment' ,
156+ 'test2.js' ,
157+ 'test3.js' ,
158+ '# Final comment' ,
159+ ] . join ( '\n' ) ) ;
160+
161+ const options = parseCliArgs ( [ '--from-file' , testFile ] ) ;
162+
163+ // Verify comments are excluded and test names are included
164+ expect ( options . tests ) . toEqual ( [ 'test1.js' , 'test2.js' , 'test3.js' ] ) ;
165+ } ) ;
166+
167+ test ( 'returns empty array for comment-only file' , ( ) => {
168+ // Create temp file with only # lines
169+ const testFile = path . join ( tempDir , 'comments-only.txt' ) ;
170+ fs . writeFileSync ( testFile , [
171+ '# Comment 1' ,
172+ '# Comment 2' ,
173+ '# Comment 3' ,
174+ ] . join ( '\n' ) ) ;
175+
176+ const options = parseCliArgs ( [ '--from-file' , testFile ] ) ;
177+
178+ // Verify empty array is returned
179+ expect ( options . tests ) . toEqual ( [ ] ) ;
180+ } ) ;
181+
182+ test ( 'preserves lines with # not at start (inline hash)' , ( ) => {
183+ // Create temp file with lines like test#1.js
184+ const testFile = path . join ( tempDir , 'inline-hash.txt' ) ;
185+ fs . writeFileSync ( testFile , [
186+ 'test#1.js' ,
187+ 'my-test#feature.js' ,
188+ 'another#test#file.js' ,
189+ ] . join ( '\n' ) ) ;
190+
191+ const options = parseCliArgs ( [ '--from-file' , testFile ] ) ;
192+
193+ // Verify lines with # not at start are preserved
194+ expect ( options . tests ) . toEqual ( [ 'test#1.js' , 'my-test#feature.js' , 'another#test#file.js' ] ) ;
195+ } ) ;
196+
197+ test ( 'preserves lines with whitespace before # as test names' , ( ) => {
198+ // Create temp file with lines like " #not-a-comment"
199+ const testFile = path . join ( tempDir , 'whitespace-hash.txt' ) ;
200+ fs . writeFileSync ( testFile , [
201+ ' #not-a-comment' ,
202+ '\t#also-not-a-comment' ,
203+ ' #test-name' ,
204+ ] . join ( '\n' ) ) ;
205+
206+ const options = parseCliArgs ( [ '--from-file' , testFile ] ) ;
207+
208+ // Verify lines with whitespace before # are preserved as test names
209+ expect ( options . tests ) . toEqual ( [ ' #not-a-comment' , '\t#also-not-a-comment' , ' #test-name' ] ) ;
210+ } ) ;
211+ } ) ;
212+
135213describe ( 'CLI config file' , ( ) => {
136214 const configFile = 'integ.config.json' ;
137215 const withConfig = ( settings : any , fileName = configFile ) => {
0 commit comments