# ghostface

> Evaluate Javascript in PhantomJS, and print the output.

Latest version **1.5.0** (published 2015-08-31) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ghostface
pnpm add ghostface
yarn add ghostface
bun add ghostface
```

Provides the command `ghostface`.

## 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 | 1.5.0 |
| Published | 2015-08-31 |
| First published | 2015-03-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Nathan Wittstock |
| Maintainers | fardog |
| Keywords | phantom, phantomjs, context, evaluate, testing, headless, browser |

## Links

- npm: https://www.npmjs.com/package/ghostface
- Repository: https://github.com/fardog/ghostface
- Issues: https://github.com/fardog/ghostface/issues
- npm.io page: https://npm.io/package/ghostface

## Dependencies (7)

- [chalk](https://npm.io/package/chalk.md) ^1.0.0
- [which](https://npm.io/package/which.md) ^1.0.9
- [semver](https://npm.io/package/semver.md) ^4.3.3
- [minimist](https://npm.io/package/minimist.md) ^1.1.1
- [source-map](https://npm.io/package/source-map.md) ^0.4.2
- [concat-stream](https://npm.io/package/concat-stream.md) ^1.4.8
- [convert-source-map](https://npm.io/package/convert-source-map.md) ^1.0.0

## 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
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2015-08-31
- 1.4.0 — 2015-08-23
- 1.3.0 — 2015-06-02
- 1.2.1 — 2015-06-02
- 1.1.4 — 2015-05-28
- 1.1.3 — 2015-05-07
- 1.1.2 — 2015-04-27
- 1.1.1 — 2015-04-25
- 1.1.0 — 2015-04-24
- 1.0.2 — 2015-04-23
- 1.0.1 — 2015-04-21
- 1.0.0 — 2015-04-21
- 0.2.0 — 2015-04-20
- 0.1.0 — 2015-03-25

## README

# ghostface

Evaluate javascript in PhantomJS, and print the output.

[![Build Status](http://img.shields.io/travis/fardog/ghostface/master.svg?style=flat)](https://travis-ci.org/fardog/ghostface)
[![npm install](http://img.shields.io/npm/dm/ghostface.svg?style=flat)](https://www.npmjs.org/package/ghostface)

Inspired by [jsdom-eval][], this module
makes it trivial to run tests in a headless browser.

## Installation

`npm install -g ghostface` will expose the `ghostface` command in your
environment.

`ghostface` does *not* include [phantomjs][] as a dependency; you should install
that however works best in your environment, and `ghostface` will find it so
long as it exists in your `$PATH`.

`ghostface` supports phantomjs versions `^1.9.0` or `^2.0.0`.

## Example

Imagine a [browserify][] project that you're testing using [tape][]:

```javascript
// file: test.js

var test = require('tape')

test('always passes', function(t) {
  t.plan(1)
  t.pass()
})
```

Run it with `ghostface`:

```bash
$ browserify test.js | ghostface | faucet
```

See the output printed to the console:

```
✓ always passes
# tests 1
# pass  1
✓ ok
```

**Note:** In the example above, we pipe output to [faucet][], which parses TAP
output and sets the correct exit codes; `ghostface` is just evaluating
javascript, it doesn't know/care what the output is, or how to set the correct
exit codes.

## Usage

```
$ ghostface --help

Usage: ghostface [options] [file]

file    Javascript file to be evaluated

Options:
  -h --html            The HTML file to be used as the page template
  -t --timeout         Milliseconds to wait for output before stopping execution. Default 1000
  -f --forever         Ignore the timeout and wait forever
  -p --phantomPath     Specify the path to the phantomjs executable
  --help               Show this message
  --version            Print version and quit
```

You can specify the JS file to be evaluated, or pipe a JS file directly into
`ghostface`. For an imaginary `file.js` in the current directory, these two
commands are equivalent:

```bash
$ ghostface file.js
$ cat file.js | ghostface
```

The JS you are evaluating will be done in a blank web page. If you want to
provide your own context, use the `--html <filename>` option to load your own
html; the JS will be evaluated after the page loads.

By default, execution is stopped if no console output is seen for over 1000ms.
You can override this timeout with `--timeout <ms>`, or choose to run forever
with `--forever`. Note you will have to send a `SIGHUP` to end execution.

## License

This project is licensed under the Apache License, Version 2.0. See
[LICENSE](./LICENSE) for the full license.

[jsdom-eval]: https://github.com/hayes/jsdom-eval
[tape]: https://github.com/substack/tape
[browserify]: https://github.com/substack/node-browserify
[faucet]: https://github.com/substack/faucet
[phantomjs]: http://phantomjs.org/

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