Skip to content

Commit e4bf2e9

Browse files
WIP
1 parent df76f5a commit e4bf2e9

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

packages/firestore/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"test:all": "run-p test:browser test:travis test:minified",
3232
"test:browser": "karma start --single-run",
3333
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
34-
"test:node": "node ./scripts/run-tests.js --main=index.node.ts --emulator 'test/**/*.test.ts'",
34+
"test:node": "node ./run-tests.js --main=index.node.ts --emulator 'test/{,!(browser)/**/}*.test.ts'",
3535
"test:node:prod": "node ./scripts/run-tests.js --main=index.node.ts 'test/{,!(browser)/**/}*.test.ts'",
3636
"test:node:persistence": "node ./scripts/run-tests.js --main=index.node.ts --persistence --emulator 'test/{,!(browser)/**/}*.test.ts'",
3737
"test:node:persistence:prod": "node ./scripts/run-tests.js --main=index.node.ts --persistence 'test/{,!(browser)/**/}*.test.ts'",
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const { resolve } = require('path');
19+
const { spawn } = require('child-process-promise');
20+
21+
const argv = require('yargs').boolean(['emulator', 'persistence']).argv;
22+
23+
const nyc = resolve(__dirname, '../../../node_modules/.bin/nyc');
24+
const mocha = resolve(__dirname, '../../../node_modules/.bin/mocha');
25+
26+
const env = {
27+
...process.env,
28+
TS_NODE_COMPILER_OPTIONS: '{"module":"commonjs"}'
29+
};
30+
31+
let args = [
32+
nyc,
33+
mocha,
34+
'--require',
35+
argv.main,
36+
'--config',
37+
'../../config/mocharc.node.js'
38+
];
39+
40+
if (argv.emulator) {
41+
env.FIRESTORE_EMULATOR_PORT = 8080;
42+
env.FIRESTORE_EMULATOR_PROJECT_ID = 'test-emulator';
43+
}
44+
45+
if (argv.persistence) {
46+
env.USE_MOCK_PERSISTENCE = 'YES';
47+
args.push('--require', 'test/util/node_persistence.ts');
48+
}
49+
50+
args = args.concat(argv._);
51+
52+
console.log(args.join(' '));
53+
54+
process.chdir(process.cwd());
55+
const childProcess = spawn(process.execPath, args, { stdio: 'inherit', env })
56+
.childProcess;
57+
58+
process.once('exit', () => childProcess.kill());
59+
process.once('SIGINT', () => childProcess.kill('SIGINT'));
60+
process.once('SIGTERM', () => childProcess.kill('SIGTERM'));

0 commit comments

Comments
 (0)