Skip to content

Commit d92d67b

Browse files
authored
Hide passed tests in CI (#2980)
* 1. Update mocha config file format 2. hide passed tests in CI * prettier * update mocha node config file name * test * use stricter regex, otherwise it matches mocha.browser.opts * [AUTOMATED]: License Headers
1 parent 74870c7 commit d92d67b

File tree

17 files changed

+83
-25
lines changed

17 files changed

+83
-25
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"args": [
1414
"test/{,!(browser)/**/}*.test.ts",
1515
"--file", "index.node.ts",
16-
"--opts", "../../config/mocha.node.opts"
16+
"--config", "../../config/mocharc.node.js"
1717
],
1818
"env": {
1919
"TS_NODE_CACHE": "NO",

config/karma.base.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,13 @@ if (false /* process.env.TRAVIS */) {
125125
config.browsers = [...config.browsers, ...Object.keys(sauceLabsBrowsers)];
126126
}
127127

128+
// Make it easy to spot failed tests in CI
129+
if (process.env.CI) {
130+
config.specReporter = {
131+
suppressErrorSummary: true,
132+
suppressPassed: true, // do not print information about passed tests
133+
suppressSkipped: true
134+
};
135+
}
136+
128137
module.exports = config;

config/mocha.browser.opts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
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+
118
# See:
219
# - https://mochajs.org/#usage for more information on usage of mocha flags.
320
# - https://github.com/karma-runner/karma-mocha for more information on all mocha flags which the
421
# karma runner supports.
22+
# This file is not converted to .mocharc.js format because karma-mocha doesn't work with it.
23+
524
--timeout 20000
625
--retry 3

config/mocha.node.opts

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

config/mocharc.node.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
/**
19+
* See:
20+
* - https://mochajs.org/#usage for more information on usage of mocha flags.
21+
* - https://github.com/karma-runner/karma-mocha for more information on all mocha flags which the
22+
* karma runner supports.
23+
*/
24+
25+
const config = {
26+
require: 'ts-node/register',
27+
timeout: 5000,
28+
retries: 5,
29+
exit: true
30+
};
31+
32+
// use min reporter in CI to make it easy to spot failed tests
33+
if (process.env.CI) {
34+
config.reporter = 'min';
35+
}
36+
37+
module.exports = config;

packages-exp/app-exp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dev": "rollup -c -w",
2121
"test": "yarn type-check && run-p lint test:browser test:node",
2222
"test:browser": "karma start --single-run",
23-
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --opts ../../config/mocha.node.opts",
23+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../config/mocharc.node.js",
2424
"type-check": "tsc -p . --noEmit",
2525
"prepare": "yarn build:release",
2626
"api-report": "api-extractor run --local --verbose",

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"type-check": "tsc -p . --noEmit",
2424
"test:browser": "karma start --single-run",
2525
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
26-
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
26+
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js",
2727
"prepare": "yarn build"
2828
},
2929
"license": "Apache-2.0",

packages/component/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"test": "yarn type-check && run-p lint test:browser test:node",
2020
"type-check": "tsc -p . --noEmit",
2121
"test:browser": "karma start --single-run",
22-
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --opts ../../config/mocha.node.opts",
22+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../config/mocharc.node.js",
2323
"prepare": "yarn build"
2424
},
2525
"dependencies": {
@@ -47,4 +47,4 @@
4747
],
4848
"reportDir": "./coverage/node"
4949
}
50-
}
50+
}

packages/database/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"test": "run-p lint test:emulator",
2020
"test:all": "run-p lint test:browser test:node",
2121
"test:browser": "karma start --single-run",
22-
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --opts ../../config/mocha.node.opts",
22+
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
2323
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/database-test-runner.ts",
2424
"prepare": "yarn build"
2525
},

packages/firestore/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"test:all": "run-p test:browser test:travis test:minified",
2121
"test:browser": "karma start --single-run",
2222
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
23-
"test:node": "FIRESTORE_EMULATOR_PORT=8080 FIRESTORE_EMULATOR_PROJECT_ID=test-emulator TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --opts ../../config/mocha.node.opts",
24-
"test:node:prod": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --opts ../../config/mocha.node.opts",
25-
"test:node:persistence": "FIRESTORE_EMULATOR_PORT=8080 FIRESTORE_EMULATOR_PROJECT_ID=test-emulator USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --require test/util/node_persistence.ts --opts ../../config/mocha.node.opts",
26-
"test:node:persistence:prod": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --require test/util/node_persistence.ts --opts ../../config/mocha.node.opts",
23+
"test:node": "FIRESTORE_EMULATOR_PORT=8080 FIRESTORE_EMULATOR_PROJECT_ID=test-emulator TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
24+
"test:node:prod": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
25+
"test:node:persistence": "FIRESTORE_EMULATOR_PORT=8080 FIRESTORE_EMULATOR_PROJECT_ID=test-emulator USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
26+
"test:node:persistence:prod": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
2727
"test:travis": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/firestore-test-runner.ts",
2828
"test:minified": "(cd ../../integration/firestore ; yarn test)",
2929
"prepare": "yarn build"

packages/functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"type-check": "tsc -p . --noEmit",
2121
"test:browser": "karma start --single-run",
2222
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
23-
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --opts ../../config/mocha.node.opts",
23+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
2424
"test:emulator": "env FIREBASE_FUNCTIONS_EMULATOR_ORIGIN=http://localhost:5005 run-p test:node",
2525
"prepare": "yarn build"
2626
},

packages/logger/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"test": "run-p lint test:browser test:node",
1919
"test:browser": "karma start --single-run",
2020
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
21-
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
21+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js",
2222
"prepare": "yarn build"
2323
},
2424
"license": "Apache-2.0",

packages/template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"dev": "rollup -c -w",
2020
"test": "yarn type-check && run-p lint test:browser test:node",
2121
"test:browser": "karma start --single-run",
22-
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.* --opts ../../config/mocha.node.opts",
22+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.* --config ../../config/mocharc.node.js",
2323
"type-check": "tsc -p . --noEmit",
2424
"prepare": "yarn build"
2525
},

packages/testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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' --opts ../../config/mocha.node.opts",
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",
1818
"prepare": "yarn build"
1919
},
2020
"license": "Apache-2.0",

packages/util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"test": "yarn type-check && run-p lint test:browser test:node",
2020
"type-check": "tsc -p . --noEmit",
2121
"test:browser": "karma start --single-run",
22-
"test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
22+
"test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js",
2323
"prepare": "yarn build"
2424
},
2525
"license": "Apache-2.0",

scripts/run_changed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const fullTestTriggerFiles = [
3434
'config/karma.base.js',
3535
'config/.eslintrc.js',
3636
'config/mocha.browser.opts',
37-
'config/mocha.node.opts',
37+
'config/mocharc.node.js',
3838
'config/tsconfig.base.json',
3939
'config/webpack.test.js',
4040
'config/firestore.rules',

tools/gitHooks/prettier.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ async function doPrettierCommit(changedFiles) {
6565
}
6666

6767
// Only run on .js or .ts files.
68-
const targetFiles = changedFiles.filter(line => line.match(/(js|ts)$/));
68+
const targetFiles = changedFiles.filter(line => line.match(/\.(js|ts)$/));
69+
6970
if (targetFiles.length === 0) {
7071
console.log('No files changed.');
7172
return;

0 commit comments

Comments
 (0)