Skip to content

Commit 781acd4

Browse files
committed
Move tests to emulator
1 parent 0f3f73b commit 781acd4

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

packages/testing/.firebaserc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

packages/testing/firebase.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"emulators": {
3+
"firestore": {
4+
"port": 9001
5+
},
6+
"database": {
7+
"port": 9000
8+
},
9+
"ui": {
10+
"enabled": false
11+
}
12+
}
13+
}

packages/testing/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"build": "rollup -c",
1515
"build:deps": "lerna run --scope @firebase/testing --include-dependencies build",
1616
"dev": "rollup -c -w",
17-
"test": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --config ../../config/mocharc.node.js",
17+
"test:nyc": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --config ../../config/mocharc.node.js",
18+
"test": "firebase emulators:exec 'yarn test:nyc'",
1819
"test:ci": "node ../../scripts/run_tests_in_ci.js",
1920
"prepare": "yarn build"
2021
},
@@ -26,9 +27,10 @@
2627
"request": "2.88.2"
2728
},
2829
"devDependencies": {
30+
"@types/request": "2.48.4",
31+
"firebase-tools": "^8.4.3",
2932
"rollup": "2.7.6",
30-
"rollup-plugin-typescript2": "0.27.0",
31-
"@types/request": "2.48.4"
33+
"rollup-plugin-typescript2": "0.27.0"
3234
},
3335
"repository": {
3436
"directory": "packages/testing",

packages/testing/test/database.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,28 @@ describe('Testing Module Tests', function() {
116116
).to.throw(/databaseName not specified/);
117117
});
118118

119-
it('loadDatabaseRules() tries to make a network request', async function() {
120-
await expect(
121-
firebase.loadDatabaseRules({ databaseName: 'foo', rules: '{}' })
122-
).to.be.rejectedWith(/ECONNREFUSED/);
119+
it('loadDatabaseRules() succeeds on valid input', async function() {
120+
await firebase.loadDatabaseRules({
121+
databaseName: 'foo',
122+
rules: '{ "rules": {} }'
123+
});
123124
});
124125

125126
it('loadFirestoreRules() succeeds on valid input', async function() {
126-
let promise = firebase.loadFirestoreRules({
127+
await firebase.loadFirestoreRules({
127128
projectId: 'foo',
128129
rules: `service cloud.firestore {
129130
match /databases/{db}/documents/{doc=**} {
130131
allow read, write;
131132
}
132133
}`
133134
});
134-
await expect(promise).to.be.rejectedWith(/ECONNREFUSED/);
135135
});
136136

137137
it('clearFirestoreData() succeeds on valid input', async function() {
138-
let promise = firebase.clearFirestoreData({
138+
await firebase.clearFirestoreData({
139139
projectId: 'foo'
140140
});
141-
await expect(promise).to.be.rejectedWith(/ECONNREFUSED/);
142141
});
143142

144143
it('apps() returns apps created with initializeTestApp', async function() {

0 commit comments

Comments
 (0)