Skip to content

Commit 1839978

Browse files
committed
chore: wip vitest flow
1 parent 6953e6b commit 1839978

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+9534
-13687
lines changed

integration_test/.gcloudignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

integration_test/.gitignore

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,72 @@
1-
node_modules/
2-
generated/
3-
.test-artifacts/
1+
# Ignored as the test runner will generate this file
2+
firebase.json
3+
4+
# Logs
5+
logs
46
*.log
5-
.DS_Store
6-
package-lock.json
7-
firebase-debug.log
8-
sa.json
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
firebase-debug.log*
11+
firebase-debug.*.log*
12+
13+
# Firebase cache
14+
.firebase/
15+
16+
# Firebase config
17+
18+
# Uncomment this if you'd like others to create their own Firebase project.
19+
# For a team working on the same Firebase project(s), it is recommended to leave
20+
# it commented so all members can deploy to the same project(s) in .firebaserc.
21+
# .firebaserc
22+
23+
# Runtime data
24+
pids
25+
*.pid
26+
*.seed
27+
*.pid.lock
28+
29+
# Directory for instrumented libs generated by jscoverage/JSCover
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
coverage
34+
35+
# nyc test coverage
36+
.nyc_output
37+
38+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
39+
.grunt
40+
41+
# Bower dependency directory (https://bower.io/)
42+
bower_components
43+
44+
# node-waf configuration
45+
.lock-wscript
46+
47+
# Compiled binary addons (http://nodejs.org/api/addons.html)
48+
build/Release
49+
50+
# Dependency directories
51+
node_modules/
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
71+
# dataconnect generated files
72+
.dataconnect

integration_test/PLAN.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Plan
2+
3+
# Structure
4+
5+
integration_test
6+
cli.ts
7+
tests <- vitest
8+
firestore.test.ts
9+
database.test.ts
10+
functions/
11+
package.json <-- "dependency": "firebase-functions": "file:../../"
12+
src/
13+
firestore.ts
14+
database.ts etc
15+
utils/ ...
16+
.gitignore <-- firebase.json
17+
18+
# Functions files
19+
20+
```ts
21+
exports.firestoreOnCreate = onDocumentCreate((event) => {
22+
firestore.collection(...).doc(...).set(event)';
23+
})
24+
```
25+
26+
```ts
27+
exports.firestoreOnCreate = onDocumentCreate((event) => {
28+
await sendEvent(event);
29+
})
30+
31+
let topic;
32+
33+
async function(name: string, event: any): Promise<void> {
34+
topic ??= await pubsub.createTopic(process.env.RUN_ID);
35+
await topic.publishMessage({ name, event })
36+
}
37+
```
38+
39+
# Test Files
40+
41+
```
42+
describe('triggers the correct document event', () => {
43+
beforeAll(() => {
44+
let event = await new Promise((resolve) => {
45+
setUpEventListener('firestoreOnCreate', (event) => {
46+
resolve(event);
47+
});
48+
49+
await admin().firestore().collection(process.env.RUN_ID).doc('foo');
50+
});
51+
52+
});
53+
54+
test('whatever...');
55+
});
56+
```
57+
58+
# CLI
59+
60+
1. Generate a run id - 1234
61+
2. Run build command in functions dir
62+
3. write a `functions.json` file, which includes:
63+
64+
```
65+
"functions": [
66+
{
67+
"source": "functions/dist",
68+
"codebase": "1234" // generated id
69+
},
70+
]
71+
```
72+
73+
4. spawns `RUN_ID=1234 firebase:deploy --only functions`
74+
5. waits....
75+
6. `RUN_ID=1234 vitest run`
76+
7. On success or error: `firebase:functions delete 1234`
77+

0 commit comments

Comments
 (0)