# tea-time

> Unit test: Tea Time!

Latest version **2.1.2** (published 2023-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install tea-time
pnpm add tea-time
yarn add tea-time
bun add tea-time
```

Provides the command `tea-time`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2023-09-04 |
| First published | 2016-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.13.0 |
| Dependencies | 15 |
| Unpacked size | 2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Cédric Ronvel |
| Maintainers | cronvel |
| Keywords | unit, test, bdd, tdd, tap, mocha |

## Links

- npm: https://www.npmjs.com/package/tea-time
- Repository: https://github.com/cronvel/tea-time
- Homepage: https://github.com/cronvel/tea-time#readme
- Issues: https://github.com/cronvel/tea-time/issues
- npm.io page: https://npm.io/package/tea-time

## Dependencies (15)

- [ws](https://npm.io/package/ws.md) ^8.13.0
- [diff](https://npm.io/package/diff.md) ^5.1.0
- [glob](https://npm.io/package/glob.md) ^10.2.3
- [dom-kit](https://npm.io/package/dom-kit.md) ^0.5.2
- [doormen](https://npm.io/package/doormen.md) ^0.15.3
- [seventh](https://npm.io/package/seventh.md) ^0.9.2
- [logfella](https://npm.io/package/logfella.md) ^2.0.1
- [tree-kit](https://npm.io/package/tree-kit.md) ^0.8.1
- [browserify](https://npm.io/package/browserify.md) ^17.0.0
- [string-kit](https://npm.io/package/string-kit.md) ^0.17.10
- [utterminal](https://npm.io/package/utterminal.md) ^0.6.0
- [terminal-kit](https://npm.io/package/terminal-kit.md) ^3.0.0
- [nextgen-events](https://npm.io/package/nextgen-events.md) ^1.5.3
- [async-try-catch](https://npm.io/package/async-try-catch.md) ^0.3.7
- [@cronvel/falafel](https://npm.io/package/@cronvel/falafel.md) ^2.2.5

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 2.1.2 (latest) — 2023-09-04
- 2.1.1 — 2023-08-17
- 2.1.0 — 2023-08-04
- 2.0.2 — 2023-05-12
- 2.0.1 — 2022-07-30
- 2.0.0 — 2022-07-30
- 1.15.0 — 2022-02-28
- 1.14.5 — 2021-08-10
- 1.14.4 — 2021-08-10
- 1.14.3 — 2021-07-21
- 1.14.2 — 2021-04-02
- 1.14.1 — 2021-03-29
- 1.14.0 — 2021-03-29
- 1.13.0 — 2021-03-18
- 1.12.0 — 2021-03-03
- … 156 more at https://npm.io/package/tea-time/versions

## README

# Unit test: Tea Time!

This is a **battery included** [mocha-compatible](http://mochajs.org/) test framework.

For the doc, start reading the [mocha documentation](http://mochajs.org/).



## Specific *Tea Time!* features:

* Many reporters can be used at once, just using multiple `--reporter` options in the CLI

* **NEW!** Promise-returning (or async function) tests and hooks

* **NEW!** Built-in *expect* assertion (but custom assertion lib can be used as well), through the `expect` global function

* **NEW!** (beta) Built-in test coverage, with in-terminal report, example:

    `tea-time -C`
  
  ... or even better using a pager:

    `tea-time -C | less -r`

* Run browser tests directly from the CLI! So you can script browser tests as well! This example will grab all test in the
  `test` directory and build a browser version of them using [Browserify](https://www.npmjs.com/package/browserify),
  create a HTML target file in the OS tmp directory, open it using Firefox, run the test in Firefox while reporting
  anything to Tea Time (using websocket behind the scene).

    `tea-time test/*js --tmp-html --ws --browserify --browser firefox`

  ... or use the shorthand:

    `tea-time test/*js --bb firefox`

* Optional tests:
	
	When an optional test fails, it does not cause a 'fail' but an 'optionalFail'.
	Optional fails don't produce non-zero exit code.
	Common use cases are next iteration preparation, or test cases created just after a bug discovery: we do not want those
	fails to prevent new releases since there is no regression.
	
	Syntaxes:
	- .optional()
	- .opt()
	- .next()
	
    ```js
    it.optional( "Optional test" , function( done ) {
        throw new Error( "Optional fail" ) ;
    } ) ;
    ```

* Better test isolation, mocha (v3.0.2 ATM) would fail to run this test properly:

    ```js
    describe( "Desync" , function() {
        
        it( "should timeout and fail after the timeout" , function( done ) {
            
            this.timeout( 100 ) ;
            
            setTimeout( function() {
                throw new Error( "Delayed fail" ) ;
            } , 200 ) ;
        } ) ;
        
        it( "should pass without being affected by the previous test after-timeout failure" , function( done ) {
            
            setTimeout( function() {
                done() ;
            } , 500 ) ;
        } ) ;
    } ) ;
    ```


## Install

Install it globally: `npm install -g tea-time`.



## Usage

Usage is: tea-time [*test files*] [*option1*] [*option2*] [...]

Available options:
```
  -h , --help             Show this help
  -C , --cover            Perform test coverage (beta feature, node.js only)
  -t , --timeout <time>   Set the default timeout for each test (default: 2000ms)
  -s , --slow <time>      Set the default slow time for each test (default: 75ms)
  -g , --grep <pattern>   Grep: filter in tests/suites by this pattern (can be used multiple times)
  -c , --console          Allow console.log() and friends
  -b , --bail             Bail after the first test failure
  -O , --skip-optional    Skip optional tests
  -R , --reporter <name>  Set/add the reporter (can be used multiple times)
 --clientReporter <name>  Set/add the client reporter (see --browser, can be used multiple times)
       --html <file>      Build one HTML file for all input test files, to run the test in browsers
       --tmp-html         Like --html but create a temporary file in the OS temp folder
       --browserify       In conjunction with --html, call Browserify to build a browser version
                          for each input files
       --ws               Start a websocket server, endpoint to the browser websocket client reporter
  -B , --browser <exe>    Open the html with the <exe> browser, need --html <file>,
                          force --ws and the websocket client reporter
       --bb <exe>         Shorthand for --tmp-html --ws --browserify --browser <exe>
```


## Reporters

* **classic**: *the default reporter*
* **one-line**: *one line status*
* **panel**: *a reporter that does not scroll (except on the final error report, if any)*
* **progress**: *a progress bar reporter*
* **tap**: *Test Anything Protocol*
* **dot**: *output colorful dots*
* **verbose**: *like classic, but more verbose*
* **report**: *use in conjunction with another reporter, only output the final status report*
* **error-report**: *use in conjunction with another reporter, only output the final error report*
* **coverage-summary**: *use in conjunction with another reporter, output partly uncovered files with percent*
* **coverage-report**: *use in conjunction with another reporter, output all uncovered lines of code*
* **notify**: *use in conjunction with another reporter, send a freedesktop.org notification with the final status report*



Browser reporters:

* **classic**: *the default reporter*
* **console**: *report everything in the browser console, using console.log()*
* **websocket**: *connect to a local Tea Time instance, and send anything to it*

---
_Source: https://npm.io/package/tea-time · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
