Skip to content

Commit 45b0591

Browse files
authored
Consolidate mocha configurations into config file. (#1469)
* Consolidate mocha configurations into config file.
1 parent 238c621 commit 45b0591

File tree

12 files changed

+26
-31
lines changed

12 files changed

+26
-31
lines changed

config/karma.base.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
const karma = require('karma');
1818
const path = require('path');
19-
const mochaConfig = require('./mocha.base');
2019
const webpackTestConfig = require('./webpack.test');
2120
const { argv } = require('yargs');
2221

@@ -102,7 +101,9 @@ const config = {
102101
singleRun: false,
103102

104103
client: {
105-
mocha: mochaConfig,
104+
mocha: {
105+
opts: `${__dirname}/mocha.browser.opts`
106+
},
106107

107108
// Pass through --grep option to filter the tests that run.
108109
args: argv.grep ? ['--grep', argv.grep] : []

config/mocha.base.js

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

config/mocha.browser.opts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# See:
2+
# - https://mochajs.org/#usage for more information on usage of mocha flags.
3+
# - https://github.com/karma-runner/karma-mocha for more information on all mocha flags which the
4+
# karma runner supports.
5+
--timeout 20000
6+
--retry 3

config/mocha.node.opts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This is the place to store default mocha options. Mocha options supplied on
2+
# command lines will override their values specified here.
3+
# See https://mochajs.org/#mochaopts for detailed usage of the mocha config file.
4+
5+
--require ts-node/register
6+
--timeout 5000
7+
--retries 5
8+
--exit

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"test": "run-p test:browser test:node",
1717
"test:browser": "karma start --single-run",
1818
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
19-
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha test/**/*.test.* --compilers ts:ts-node/register/type-check --exit",
19+
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
2020
"prepare": "npm run build"
2121
},
2222
"license": "Apache-2.0",

packages/database/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dev": "rollup -c -w",
1515
"test": "run-p test:browser test:node",
1616
"test:browser": "karma start --single-run",
17-
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --compilers ts:ts-node/register/type-check -r src/nodePatches.ts --retries 5 --timeout 5000 --exit",
17+
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' -r src/nodePatches.ts --opts ../../config/mocha.node.opts",
1818
"prepare": "npm run build"
1919
},
2020
"license": "Apache-2.0",

packages/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"test:all": "run-p test:browser test:node",
1414
"test:browser": "karma start --single-run",
1515
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
16-
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register/type-check --require index.node.ts --retries 5 --timeout 5000 --exit",
17-
"test:node:persistence": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register/type-check --require index.node.ts --require test/util/node_persistence.ts --retries 5 --timeout 5000 --exit",
16+
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require index.node.ts --opts ../../config/mocha.node.opts",
17+
"test:node:persistence": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require index.node.ts --require test/util/node_persistence.ts --opts ../../config/mocha.node.opts",
1818
"prepare": "npm run build"
1919
},
2020
"main": "dist/index.node.cjs.js",

packages/functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"test": "run-p test:browser test:node",
1616
"test:browser": "karma start --single-run",
1717
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
18-
"test:node": "nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --retries 5 --timeout 5000 --exit",
18+
"test:node": "nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require index.node.ts --opts ../../config/mocha.node.opts",
1919
"test:emulator": "env FIREBASE_FUNCTIONS_EMULATOR_ORIGIN=http://localhost:5005 run-p test:node",
2020
"prepare": "npm run build"
2121
},

packages/logger/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"test": "run-p test:browser test:node",
1515
"test:browser": "karma start --single-run",
1616
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
17-
"test:node": "nyc --reporter lcovonly -- mocha test/**/*.test.* --compilers ts:ts-node/register --exit",
17+
"test:node": "nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
1818
"prepare": "npm run build"
1919
},
2020
"license": "Apache-2.0",

packages/template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dev": "rollup -c -w",
1616
"test": "run-p test:browser test:node",
1717
"test:browser": "karma start --single-run",
18-
"test:node": "nyc --reporter lcovonly -- mocha test/**/*.test.* --compilers ts:ts-node/register --exit",
18+
"test:node": "nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
1919
"prepare": "npm run build"
2020
},
2121
"peerDependencies": {

packages/testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"build": "rollup -c",
1212
"dev": "rollup -c -w",
13-
"test": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register/type-check --retries 5 --timeout 5000 --exit",
13+
"test": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --opts ../../config/mocha.node.opts",
1414
"prepare": "npm run build"
1515
},
1616
"license": "Apache-2.0",

packages/util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dev": "rollup -c -w",
1515
"test": "run-p test:browser test:node",
1616
"test:browser": "karma start --single-run",
17-
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha test/**/*.test.* --compilers ts:ts-node/register/type-check --exit",
17+
"test:node": "TS_NODE_CACHE=NO nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
1818
"prepare": "npm run build"
1919
},
2020
"license": "Apache-2.0",

0 commit comments

Comments
 (0)