@@ -49,12 +49,17 @@ export function setupFirestoreRefs() {
49
49
const testsCollection = collection ( firestore , `__tests` )
50
50
const itemRef = doc ( testsCollection )
51
51
// let firestore generate the id
52
- const forItemsRef = doc ( testsCollection )
52
+ const forCollectionRefs = doc ( testsCollection )
53
+ const forDocRefs = collection ( forCollectionRefs , 'docs' )
53
54
54
- const listRef = collection ( forItemsRef , 'list' )
55
+ const listRef = collection ( forCollectionRefs , 'list' )
55
56
const orderedListRef = firestoreQuery ( listRef , orderBy ( 'name' ) )
56
57
57
58
afterAll ( async ( ) => {
59
+ // cleaning up creates unexpected errors and is only necessary during dev
60
+ if ( process . env . CI ) {
61
+ return
62
+ }
58
63
// clean up the tests data
59
64
await Promise . all ( [
60
65
deleteDoc ( itemRef ) ,
@@ -63,12 +68,13 @@ export function setupFirestoreRefs() {
63
68
await Promise . all (
64
69
[ ...collectionsToClean ] . map ( ( collection ) => clearCollection ( collection ) )
65
70
)
71
+ await clearCollection ( forDocRefs )
66
72
// 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
+ ] )
72
78
} )
73
79
74
80
// for automatically generated collections
@@ -80,7 +86,7 @@ export function setupFirestoreRefs() {
80
86
) {
81
87
path = path || `col_${ collectionId ++ } `
82
88
83
- const col = collection ( forItemsRef , path , ...pathSegments )
89
+ const col = collection ( forCollectionRefs , path , ...pathSegments )
84
90
collectionsToClean . add ( col )
85
91
// to avoid having to pass a converter for types
86
92
return col as CollectionReference < T >
@@ -91,7 +97,7 @@ export function setupFirestoreRefs() {
91
97
const docsToClean = new Set < DocumentReference < any > > ( )
92
98
function _doc < T = unknown > ( path ?: string , ...pathSegments : string [ ] ) {
93
99
path = path || `doc_${ docId ++ } `
94
- const d = doc ( testsCollection , path , ...pathSegments )
100
+ const d = doc ( forDocRefs , path , ...pathSegments )
95
101
docsToClean . add ( d )
96
102
// to avoid having to pass a converter for types
97
103
return d as DocumentReference < T >
@@ -130,7 +136,7 @@ export function setupFirestoreRefs() {
130
136
listRef,
131
137
orderedListRef,
132
138
testId,
133
- col : forItemsRef ,
139
+ col : forCollectionRefs ,
134
140
collection : _collection ,
135
141
doc : _doc ,
136
142
query : firestoreQuery ,
0 commit comments