Skip to content

Commit

Permalink
Banner to separate test output (#1190)
Browse files Browse the repository at this point in the history
* cli: add mocha-banner so we can see what each test outputs

* linting
  • Loading branch information
bahmutov authored and brian-mann committed Jan 16, 2018
1 parent ae8b147 commit 9930226
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
5 changes: 3 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand All @@ -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": {
Expand Down
8 changes: 5 additions & 3 deletions cli/test/lib/cli_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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' })
})
Expand All @@ -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 })
})
Expand All @@ -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' })
})
Expand Down
2 changes: 2 additions & 0 deletions cli/test/lib/tasks/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 2 additions & 0 deletions cli/test/lib/tasks/install_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const downloadDestination = {
}

describe('install', function () {
require('mocha-banner').register()

beforeEach(function () {
this.stdout = stdout.capture()

Expand Down
12 changes: 6 additions & 6 deletions cli/test/lib/tasks/unzip_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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',
})
Expand All @@ -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(() => {
Expand Down
1 change: 1 addition & 0 deletions cli/test/lib/tasks/verify_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const slice = (str) => {
}

context('.verify', function () {
require('mocha-banner').register()
beforeEach(function () {
this.stdout = stdout.capture()
this.cpstderr = new EE()
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9930226

Please sign in to comment.