Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
fix: add TEST_OUTPUT flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 1, 2018
1 parent 077d2aa commit 8de6fb7
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 795 deletions.
27 changes: 9 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,31 @@ jobs:
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{checksum ".circleci/config.yml"}}-master-
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn test
- run: curl -s https://codecov.io/bash | bash
- run: .circleci/test
- store_test_results: &store_test_results
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn
node-8:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn test
- run: curl -s https://codecov.io/bash | bash
- run: .circleci/test
- store_test_results: *store_test_results
release:
<<: *test
steps:
- add_ssh_keys
- checkout
- restore_cache: *restore_cache
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn add -D @dxcli/semantic-release@1
- run: yarn exec nps release
- run: .circleci/release
- save_cache: &save_cache
key: v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn

workflows:
version: 2
Expand Down
11 changes: 11 additions & 0 deletions .circleci/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -ex

.circleci/setup_git

PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH

yarn global add @dxcli/semantic-release@1 semantic-release@12
yarn install --frozen-lockfile
semantic-release -e @dxcli/semantic-release
7 changes: 7 additions & 0 deletions .circleci/yarn → .circleci/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -ex

.circleci/setup_git

PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH

CLI_ENGINE_UTIL_YARN_ARGS="--frozen-lockfile"
Expand All @@ -20,3 +22,8 @@ yarn install $CLI_ENGINE_UTIL_YARN_ARGS
if [[ "$CLI_ENGINE_GREENKEEPER_BRANCH" == 1 ]]; then
greenkeeper-lockfile-upload
fi

yarn add -D nyc @dxcli/nyc-config
yarn test

curl -s https://codecov.io/bash | bash
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,11 @@ Stdout/Stderr Mocking
---------------------

This is used for tests that ensure that certain stdout/stderr messages are made.
By default this also trims the output from the screen.
By default this also trims the output from the screen. See the output by setting `TEST_OUTPUT=1` or `DEBUG=stdout|stderr`, or by setting `{print: true}` in the options passed.

You can use the library [stdout-stderr](https://npm.im/stdout-stderr) directly for doing this, but you have to be careful to always reset it after the tests run. We do that work for you so you don't have to worry about mocha's output being hidden.

```js
import chalk from 'chalk'

describe('stdmock tests', () => {
fancy
.stdout()
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
- git submodule update --init --recursive
- git config --global user.email "[email protected]"
- git config --global user.name "dxcli"
- yarn
- yarn add -D nyc @dxcli/nyc-config
test_script:
- yarn test
after_test:
Expand Down
1 change: 0 additions & 1 deletion package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@ module.exports = {
lint: concurrent(linters),
test,
mocha,
release: 'dxcli-semantic-release -e @dxcli/semantic-release',
},
}
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
"bugs": "https://github.com/jdxcode/fancy-test/issues",
"dependencies": {
"lodash": "^4.17.4",
"stdout-stderr": "^0.1.5"
"stdout-stderr": "^0.1.6"
},
"devDependencies": {
"@commitlint/cli": "^6.0.2",
"@commitlint/config-conventional": "^6.0.2",
"@dxcli/dev": "^2.0.16",
"@dxcli/nyc-config": "^0.0.4",
"@dxcli/semantic-release": "1",
"@commitlint/cli": "^6.0.5",
"@commitlint/config-conventional": "^6.0.4",
"@dxcli/tslint": "^0.1.3",
"@types/chai": "^4.1.2",
"@types/lodash": "^4.14.99",
"@types/mocha": "^2.2.48",
"@types/nock": "^9.1.2",
"@types/node": "^9.4.0",
"@types/node-notifier": "^0.0.28",
"@types/read-pkg": "^3.0.0",
"@types/sinon": "^4.1.3",
"chai": "^4.1.2",
"chalk": "^2.3.0",
"eslint": "^4.16.0",
"eslint-config-dxcli": "^1.2.1",
"http-call": "^5.0.2",
"husky": "^0.14.3",
"mocha": "^5.0.0",
Expand All @@ -28,7 +33,7 @@
"nps-utils": "^1.5.0",
"sinon": "^4.2.2",
"ts-node": "^4.1.0",
"typescript": "^2.6.2"
"typescript": "^2.7.1"
},
"engines": {
"node": ">=8.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/stdmock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as mock from 'stdout-stderr'
const create = <T extends 'stdout' | 'stderr'>(std: T) => (opts: {print?: boolean, stripColor?: boolean} = {}) => ({
run(ctx: {readonly [P in T]: string}) {
mock[std].start()
mock[std].print = opts.print === true
mock[std].print = opts.print || process.env.TEST_OUTPUT === '1'
mock[std].stripColor = opts.stripColor !== false
if (ctx[std] as any !== undefined) return
Object.defineProperty(ctx, std, {
Expand Down
Loading

0 comments on commit 8de6fb7

Please sign in to comment.