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

Commit

Permalink
fix: allow resetting stdmock
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 27, 2018
1 parent 84b4c18 commit ceabe22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/stdmock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const create = <T extends 'stdout' | 'stderr'>(std: T) => (opts: {print?: boolea
mock[std].start()
mock[std].print = opts.print === true
mock[std].stripColor = opts.stripColor !== false
if (ctx[std] as any !== undefined) return
Object.defineProperty(ctx, std, {
get: () => mock[std].output
})
Expand Down
9 changes: 9 additions & 0 deletions test/stdmock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,13 @@ describe('stdout', () => {
console.log(chalk.red('foobar'))
expect(output.stdout).to.contain(chalk.red('foobar'))
})

fancy
.stdout()
.do(() => console.log('foo'))
.do(c => expect(c.stdout).to.equal('foo\n'))
.stdout()
.do(() => console.log('bar'))
.do(c => expect(c.stdout).to.equal('bar\n'))
.it('resets stdout')
})

0 comments on commit ceabe22

Please sign in to comment.