# totoro-server

> Server side of totoro.

Latest version **2.0.3** (published 2014-12-25) · 0 weekly downloads

## Install

```sh
npm install totoro-server
pnpm add totoro-server
yarn add totoro-server
bun add totoro-server
```

Provides the command `totoro-server`.

## 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.0.3 |
| Published | 2014-12-25 |
| First published | 2013-05-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.12 |
| Dependencies | 12 |
| Known vulnerabilities | 0 (+8 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 63 |
| Author | fool2fish |
| Maintainers | kangpangpang, fool2fish |
| Keywords | front-end, cross-browser, testing, tool, totoro, server |

## Links

- npm: https://www.npmjs.com/package/totoro-server
- Repository: git@github.com:totorojs/totoro-server
- Homepage: https://github.com/totorojs/totoro-server
- Issues: https://github.com/totorojs/totoro-server/issues
- npm.io page: https://npm.io/package/totoro-server

## Dependencies (12)

- [when](https://npm.io/package/when.md) ~3.4.6
- [utilx](https://npm.io/package/utilx.md) ~0.0.8
- [tracer](https://npm.io/package/tracer.md) ~0.7.3
- [express](https://npm.io/package/express.md) ~4.9.0
- [request](https://npm.io/package/request.md) ~2.44.0
- [colorful](https://npm.io/package/colorful.md) ~2.1.0
- [detector](https://npm.io/package/detector.md) ~2.1.1
- [commander](https://npm.io/package/commander.md) ~2.3.0
- [socket.io](https://npm.io/package/socket.io.md) ~1.1.0
- [iconv-lite](https://npm.io/package/iconv-lite.md) ~0.4.4
- [jscoverage](https://npm.io/package/jscoverage.md) 0.3.7
- [body-parser](https://npm.io/package/body-parser.md) ~1.8.2

## 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.0.3 (latest) — 2014-12-25
- 2.0.0 — 2014-11-05
- 1.0.2 — 2014-06-03
- 1.0.0 — 2014-05-22
- 0.5.4 — 2014-03-06
- 0.5.3 — 2014-03-05
- 0.5.1 — 2014-02-28
- 0.5.0 — 2014-02-28
- 0.4.1 — 2013-10-09
- 0.4.0 — 2013-09-29
- 0.3.5 — 2013-08-14
- 0.3.4 — 2013-08-08
- 0.3.3 — 2013-08-05
- 0.3.2 — 2013-08-01
- 0.3.1 — 2013-08-01
- … 5 more at https://npm.io/package/totoro-server/versions

## README

![totoro](https://f.cloud.github.com/assets/340282/891339/657d9018-fa54-11e2-9760-6955388fd8fc.jpg)

# totoro-server

Server side of totoro.

Latest stable version：v2.0

---

## 1. Installation

### Node requirement

\>= 0.10.12

### Install from npm

```
$ npm install totoro-server -g
```

If it not works, you may add `sudo` before the command, as follows.

### Install from github

To get the latest function (may not be stable)

```
$ git clone git@github.com:totorojs/totoro-server.git
$ cd totoro-server
$ npm install -g
```

## 2. Quick Start

1. Launch server.

    ```
    $ totoro-server
    ```

    You should see an output like bellow:

    ```
    Start server <{{yourIP}}:9999>
    ```

2. Start a driver

    Use any browser to visit {{yourIP}}:9999, then it registers as a **web driver** that can drive the browser of this kind run test.

    If you use it on pc, be mind that allow popup from {{yourIP}}, refer to [popup settings](https://github.com/totorojs/totoro-server/wiki/Popup-Settings.zh).

Want to run some test? See the [quick start of totoro](https://github.com/totorojs/totoro#totoro).


## 3. What Is A Driver?

In a word, a driver is something open specified browser to visit specified URL and close it by directives from server.

### Available drivers

##### Official drivers

- [web driver](http://server.totorojs.org:9999): any browser opens {{yourIP}}:9999 becomes a web driver, it's for temporary use only.
- [totoro-driver](https://github.com/totorojs/totoro-driver): a stable driver written in node, be able to drive chrome, safari, firefox and ie both on windows and mac.

##### Third party drivers

- [totoro-phantomjs](https://github.com/fengmk2/totoro-phantomjs)
- [totoro-driver-ios](https://github.com/sorrycc/totoro-driver-ios)
- [totoro-driver-android](https://github.com/semious/totoro-android)

[Add your driver here](https://github.com/totorojs/totoro-server/issues/new)

### How to write a driver?

If you know how to open and close a browser(or some other application), it's very very easy to write a driver for it.

All steps with pseudo-code.

1. Set command line options

    - `-s, --server`: default is `http://server.totorojs.org:9999`

2. Link to server by socket and init.

    ```
    var socket = socketClient.connect({{server}} + '/__labor')
    // NOTE: the namespace of socket is '/__labor'

    socket.on('connect', function() {
      var initInfo = {
        // if the app you drive is not a browser
        // group is required, it could be any string you like
        group: 'groupName',
        device: { name: 'mac' },
        os: { name: 'macosx', version: '13.1.0' },
        agent: { name: 'chrome', version:'35.0.1916.114' }
      }

      socket.emit('init', initInfo)
    })
    ```

3. Open or close specified browser when received corresponding directives.

    ```
    socket.on('add', function(data) {
      /*
       * structure of data
       * {
       *   orderId: {{orderId}},
       *   laborId: {{laborId}},
       *   laborTrait: {{labor trait info, the same as init info}},
       *   runner: {{test runner, typically be a url}}
       * }
       */
      var key = data.orderId + '-' + data.laborId
      orders[key] = open(runner)
    })

    socket.on('remove', function(data) {
      // the data structure is the same as 'add' event's but without the laborTrait
      var key = data.orderId + '-' + data.laborId
      close(orders[key])
      ;delete orders[key]
    })
    ```

4. Close all browsers when dirver exits.


## 4. Cli Options

#### -H, --host

Server host。

Default: IP of this computer.

#### -P, --port

Server port。

Default: 9999

#### -d, --debug

Show debug log.

Default: false

## 5. Config File

If you need a config file, just place `totoro-srever-config.json` in the CWD, all options are written in lower camel case.

## Data flow

![1](http://uml.mvnsearch.org/gist/dd566fc963f1863d82e2)

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