Skip to content

Commit

Permalink
More concise unit test running (#1650)
Browse files Browse the repository at this point in the history
* mocha report in dot format

* silence the CLI tests from logging out.
  • Loading branch information
paulirish authored and brendankenny committed Feb 7, 2017
1 parent 08611ab commit 5403bc3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions lighthouse-cli/test/cli/chrome-launcher-test.js
Expand Up @@ -19,15 +19,18 @@
require('../../compiled-check.js')('chrome-launcher.js');

const ChromeLauncher = require('../../chrome-launcher.js').ChromeLauncher;
const log = require('../../../lighthouse-core/lib/log');
const assert = require('assert');

/* eslint-env mocha */

describe('ChromeLauncher', () => {
it('doesn\'t fail when killed twice', () => {
log.setLevel('error');
const chromeInstance = new ChromeLauncher();
return chromeInstance.run()
.then(() => {
log.setLevel();
return Promise.all([
chromeInstance.kill(),
chromeInstance.kill()
Expand All @@ -36,6 +39,7 @@ describe('ChromeLauncher', () => {
});

it('doesn\'t launch multiple chrome processes', () => {
log.setLevel('error');
const chromeInstance = new ChromeLauncher();
let pid;
return chromeInstance.run()
Expand All @@ -44,6 +48,7 @@ describe('ChromeLauncher', () => {
return chromeInstance.run();
})
.then(() => {
log.setLevel();
assert.strictEqual(pid, chromeInstance.chrome.pid);
return chromeInstance.kill();
});
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/test/cli/index-test.js
Expand Up @@ -22,7 +22,7 @@ const childProcess = require('child_process');

describe('CLI Tests', function() {
it('fails if a url is not provided', () => {
assert.throws(() => childProcess.execSync('node lighthouse-cli/index.js'),
assert.throws(() => childProcess.execSync('node lighthouse-cli/index.js', {stdio: 'pipe'}),
/Please provide a url/);
});

Expand Down
6 changes: 0 additions & 6 deletions lighthouse-core/formatters/partials/speedline.html
@@ -1,9 +1,3 @@
<style>
.speedline-measures {
font-size: 14px
}
</style>

<ul class="subitem__details">
<li class="subitem__detail">First Visual Change: <strong>{{this.timings.firstVisualChange}}ms</strong></li>
<li class="subitem__detail">Last Visual Change: <strong>{{this.timings.visuallyComplete}}ms</strong></li>
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/lib/log.js
Expand Up @@ -87,13 +87,13 @@ class Log {
static setLevel(level) {
switch (level) {
case 'silent':
debug.disable();
debug.enable('-*');
break;
case 'verbose':
debug.enable('*');
break;
case 'error':
debug.enable('*:error');
debug.enable('-*, *:error');
break;
default:
debug.enable('*, -*:verbose');
Expand Down
6 changes: 4 additions & 2 deletions lighthouse-core/scripts/run-mocha.sh
Expand Up @@ -3,7 +3,7 @@
flag=$1

function _runmocha() {
mocha $2 $(find $1/test -name '*-test.js') --timeout 60000;
mocha --reporter dot $2 $(find $1/test -name '*-test.js') --timeout 60000;
}

if [ "$flag" == '--watch' ]; then
Expand All @@ -15,5 +15,7 @@ elif [ "$flag" == '--viewer' ]; then
elif [ "$flag" == '--core' ]; then
_runmocha 'lighthouse-core'
else
_runmocha 'lighthouse-cli' && _runmocha 'lighthouse-core' && _runmocha 'lighthouse-viewer'
echo "lighthouse-core tests" && _runmocha 'lighthouse-core' && \
echo "lighthouse-cli tests" && _runmocha 'lighthouse-cli' && \
echo "lighthouse-viewer tests" && _runmocha 'lighthouse-viewer'
fi

0 comments on commit 5403bc3

Please sign in to comment.