@@ -49,12 +49,17 @@ export function setupFirestoreRefs() {
4949 const testsCollection = collection ( firestore , `__tests` )
5050 const itemRef = doc ( testsCollection )
5151 // let firestore generate the id
52- const forItemsRef = doc ( testsCollection )
52+ const forCollectionRefs = doc ( testsCollection )
53+ const forDocRefs = collection ( forCollectionRefs , 'docs' )
5354
54- const listRef = collection ( forItemsRef , 'list' )
55+ const listRef = collection ( forCollectionRefs , 'list' )
5556 const orderedListRef = firestoreQuery ( listRef , orderBy ( 'name' ) )
5657
5758 afterAll ( async ( ) => {
59+ // cleaning up creates unexpected errors and is only necessary during dev
60+ if ( process . env . CI ) {
61+ return
62+ }
5863 // clean up the tests data
5964 await Promise . all ( [
6065 deleteDoc ( itemRef ) ,
@@ -63,12 +68,13 @@ export function setupFirestoreRefs() {
6368 await Promise . all (
6469 [ ...collectionsToClean ] . map ( ( collection ) => clearCollection ( collection ) )
6570 )
71+ await clearCollection ( forDocRefs )
6672 // must be done after the cleanup of its docs
67- await deleteDoc ( forItemsRef ) ,
68- await Promise . all ( [
69- clearCollection ( listRef ) ,
70- clearCollection ( testsCollection ) ,
71- ] )
73+ await deleteDoc ( forCollectionRefs )
74+ await Promise . all ( [
75+ clearCollection ( listRef ) ,
76+ clearCollection ( testsCollection ) ,
77+ ] )
7278 } )
7379
7480 // for automatically generated collections
@@ -80,7 +86,7 @@ export function setupFirestoreRefs() {
8086 ) {
8187 path = path || `col_${ collectionId ++ } `
8288
83- const col = collection ( forItemsRef , path , ...pathSegments )
89+ const col = collection ( forCollectionRefs , path , ...pathSegments )
8490 collectionsToClean . add ( col )
8591 // to avoid having to pass a converter for types
8692 return col as CollectionReference < T >
@@ -91,7 +97,7 @@ export function setupFirestoreRefs() {
9197 const docsToClean = new Set < DocumentReference < any > > ( )
9298 function _doc < T = unknown > ( path ?: string , ...pathSegments : string [ ] ) {
9399 path = path || `doc_${ docId ++ } `
94- const d = doc ( testsCollection , path , ...pathSegments )
100+ const d = doc ( forDocRefs , path , ...pathSegments )
95101 docsToClean . add ( d )
96102 // to avoid having to pass a converter for types
97103 return d as DocumentReference < T >
@@ -130,7 +136,7 @@ export function setupFirestoreRefs() {
130136 listRef,
131137 orderedListRef,
132138 testId,
133- col : forItemsRef ,
139+ col : forCollectionRefs ,
134140 collection : _collection ,
135141 doc : _doc ,
136142 query : firestoreQuery ,
0 commit comments