@@ -68,6 +68,24 @@ describe("parseTestFiles", () => {
6868 ] ) ;
6969 } ) ;
7070
71+ it ( "ignores non-yaml files" , async ( ) => {
72+ writeFile (
73+ "my_test.yaml" ,
74+ stringify ( {
75+ tests : [ { displayName : "my test" , steps : [ { goal : "click a button" } ] } ] ,
76+ } ) ,
77+ ) ;
78+ writeFile (
79+ "my_test.txt" ,
80+ stringify ( {
81+ tests : [ { displayName : "should not be parsed" , steps : [ { goal : "do nothing" } ] } ] ,
82+ } ) ,
83+ ) ;
84+ const tests = await parseTestFiles ( tempdir . name , "http://www.foo.com" ) ;
85+ expect ( tests . length ) . to . equal ( 1 ) ;
86+ expect ( tests [ 0 ] . testCase . displayName ) . to . equal ( "my test" ) ;
87+ } ) ;
88+
7189 it ( "parses the sample test case file" , async ( ) => {
7290 writeFile ( "smoke_test.yaml" , readTemplateSync ( "init/apptesting/smoke_test.yaml" ) ) ;
7391 const tests = await parseTestFiles ( tempdir . name , "http://www.foo.com" ) ;
@@ -181,39 +199,39 @@ describe("parseTestFiles", () => {
181199 }
182200
183201 it ( "returns an empty list if no match" , async ( ) => {
184- writeFile ( "aaa" , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
185- writeFile ( "bbb" , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
202+ writeFile ( "aaa.yaml " , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
203+ writeFile ( "bbb.yaml " , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
186204 expect ( await getTestCaseNames ( "yyy" ) ) . to . eql ( [ ] ) ;
187205 } ) ;
188206
189207 it ( "filters on filename" , async ( ) => {
190- writeFile ( "aaa" , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
191- writeFile ( "bbb" , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
208+ writeFile ( "aaa.yaml " , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
209+ writeFile ( "bbb.yaml " , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
192210 expect ( await getTestCaseNames ( "aaa" ) ) . to . eql ( [ "axx" , "ayy" , "azz" ] ) ;
193211 } ) ;
194212
195213 it ( "filters on test case name" , async ( ) => {
196- writeFile ( "aaa" , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
197- writeFile ( "bbb" , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
214+ writeFile ( "aaa.yaml " , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
215+ writeFile ( "bbb.yaml " , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
198216 expect ( await getTestCaseNames ( "" , ".xx" ) ) . to . eql ( [ "axx" , "bxx" ] ) ;
199217 } ) ;
200218
201219 it ( "filters on filename and test case name" , async ( ) => {
202- writeFile ( "aaa" , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
203- writeFile ( "bbb" , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
204- expect ( await getTestCaseNames ( "a $" , "xx" ) ) . to . eql ( [ "axx" ] ) ;
220+ writeFile ( "aaa.yaml " , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
221+ writeFile ( "bbb.yaml " , createBasicTest ( [ "bxx" , "byy" , "bzz" ] ) ) ;
222+ expect ( await getTestCaseNames ( "aaa\\.yaml $" , "xx" ) ) . to . eql ( [ "axx" ] ) ;
205223 } ) ;
206224
207225 it ( "throws an error for invalid filename regex" , async ( ) => {
208- writeFile ( "aaa" , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
226+ writeFile ( "aaa.yaml " , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
209227 await expect ( getTestCaseNames ( "*.txt" ) ) . to . be . rejectedWith (
210228 FirebaseError ,
211229 "Invalid file pattern regex: *.txt" ,
212230 ) ;
213231 } ) ;
214232
215233 it ( "throws an error for invalid test case name regex" , async ( ) => {
216- writeFile ( "aaa" , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
234+ writeFile ( "aaa.yaml " , createBasicTest ( [ "axx" , "ayy" , "azz" ] ) ) ;
217235 await expect ( getTestCaseNames ( "" , "*.txt" ) ) . to . be . rejectedWith (
218236 FirebaseError ,
219237 "Invalid test name pattern regex: *.txt" ,
0 commit comments