From 99302267dfd37cf6e8ff69b7b2542a89c9203abf Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Tue, 16 Jan 2018 13:22:00 -0500 Subject: [PATCH] Banner to separate test output (#1190) * cli: add mocha-banner so we can see what each test outputs * linting --- cli/package.json | 5 +++-- cli/test/lib/cli_spec.js | 8 +++++--- cli/test/lib/tasks/download_spec.js | 2 ++ cli/test/lib/tasks/install_spec.js | 2 ++ cli/test/lib/tasks/unzip_spec.js | 12 ++++++------ cli/test/lib/tasks/verify_spec.js | 1 + package.json | 1 + 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/cli/package.json b/cli/package.json index 415e0e9e6070..02571cfe5628 100644 --- a/cli/package.json +++ b/cli/package.json @@ -11,7 +11,7 @@ }, "scripts": { "test": "npm run test-unit", - "test-unit": "npm run dtslint && bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../mocha-reporter-config.json", + "test-unit": "npm run dtslint && npm run unit", "test-watch": "bin-up mocha --watch", "test-dependencies": "bin-up deps-ok && dependency-check . --no-dev", "test-debug": "node --inspect --debug-brk $(bin-up _mocha)", @@ -21,7 +21,8 @@ "build": "node ./scripts/build.js", "prerelease": "npm run build", "release": "cd build && releaser --no-node --no-changelog", - "size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";" + "size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";", + "unit": "bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../mocha-reporter-config.json" }, "types": "types", "dependencies": { diff --git a/cli/test/lib/cli_spec.js b/cli/test/lib/cli_spec.js index 6f84e62c8c7a..918c6ac5c973 100644 --- a/cli/test/lib/cli_spec.js +++ b/cli/test/lib/cli_spec.js @@ -13,6 +13,8 @@ const execa = require('execa-wrap') const path = require('path') describe('cli', function () { + require('mocha-banner').register() + beforeEach(function () { logger.reset() this.sandbox.stub(process, 'exit') @@ -181,7 +183,7 @@ describe('cli', function () { it('calls run with relative --project folder', function () { this.sandbox.stub(path, 'resolve') - .withArgs('foo/bar').returns('/mock/absolute/foo/bar') + .withArgs('foo/bar').returns('/mock/absolute/foo/bar') this.exec('run --project foo/bar') expect(run.start).to.be.calledWith({ project: '/mock/absolute/foo/bar' }) }) @@ -191,7 +193,7 @@ describe('cli', function () { expect(run.start).to.be.calledWith({ project: '/tmp/foo/bar' }) }) - it('calls run with heded', function () { + it('calls run with headed', function () { this.exec('run --headed') expect(run.start).to.be.calledWith({ headed: true }) }) @@ -204,7 +206,7 @@ describe('cli', function () { it('calls open.start with relative --project folder', function () { this.sandbox.stub(path, 'resolve') - .withArgs('foo/bar').returns('/mock/absolute/foo/bar') + .withArgs('foo/bar').returns('/mock/absolute/foo/bar') this.exec('open --project foo/bar') expect(open.start).to.be.calledWith({ project: '/mock/absolute/foo/bar' }) }) diff --git a/cli/test/lib/tasks/download_spec.js b/cli/test/lib/tasks/download_spec.js index e9784ba95155..8ce2b87f6372 100644 --- a/cli/test/lib/tasks/download_spec.js +++ b/cli/test/lib/tasks/download_spec.js @@ -16,6 +16,8 @@ const stdout = require('../../support/stdout') const normalize = require('../../support/normalize') describe('download', function () { + require('mocha-banner').register() + const rootFolder = '/home/user/git' beforeEach(function () { diff --git a/cli/test/lib/tasks/install_spec.js b/cli/test/lib/tasks/install_spec.js index fe8ce26977de..38fa733567a0 100644 --- a/cli/test/lib/tasks/install_spec.js +++ b/cli/test/lib/tasks/install_spec.js @@ -23,6 +23,8 @@ const downloadDestination = { } describe('install', function () { + require('mocha-banner').register() + beforeEach(function () { this.stdout = stdout.capture() diff --git a/cli/test/lib/tasks/unzip_spec.js b/cli/test/lib/tasks/unzip_spec.js index 9c8944fb6bea..1f8fcbe8e80c 100644 --- a/cli/test/lib/tasks/unzip_spec.js +++ b/cli/test/lib/tasks/unzip_spec.js @@ -16,6 +16,7 @@ const normalize = require('../../support/normalize') const dest = info.getInstallationDir() describe('unzip', function () { + require('mocha-banner').register() beforeEach(function () { this.stdout = stdout.capture() @@ -33,7 +34,8 @@ describe('unzip', function () { it('throws when cannot unzip', function () { const ctx = this - return unzip.start({ + return unzip + .start({ downloadDestination: path.join('test', 'fixture', 'bad_example.zip'), zipDestination: '/foo/bar/baz', }) @@ -43,15 +45,13 @@ describe('unzip', function () { .catch((err) => { logger.error(err) - snapshot( - 'unzip error', - normalize(ctx.stdout.toString()) - ) + snapshot('unzip error', normalize(ctx.stdout.toString())) }) }) it('can really unzip', function () { - return unzip.start({ + return unzip + .start({ downloadDestination: path.join('test', 'fixture', 'example.zip'), }) .then(() => { diff --git a/cli/test/lib/tasks/verify_spec.js b/cli/test/lib/tasks/verify_spec.js index ab77f21a9f5d..fd861a7b2d58 100644 --- a/cli/test/lib/tasks/verify_spec.js +++ b/cli/test/lib/tasks/verify_spec.js @@ -43,6 +43,7 @@ const slice = (str) => { } context('.verify', function () { + require('mocha-banner').register() beforeEach(function () { this.stdout = stdout.capture() this.cpstderr = new EE() diff --git a/package.json b/package.json index 59cd6e025f47..d6dc9f662f4f 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "lodash": "^4.17.4", "make-empty-github-commit": "^1.2.0", "mocha": "^3.5.0", + "mocha-banner": "^1.1.0", "mocha-junit-reporter": "^1.13.0", "mocha-multi-reporters": "^1.1.5", "obfuscator": "^0.5.4",