# gulp-mocha-docker

> A simple gulp task to run mocha tests within a running container

Latest version **1.0.5** (published 2017-02-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install gulp-mocha-docker
pnpm add gulp-mocha-docker
yarn add gulp-mocha-docker
bun add gulp-mocha-docker
```

## 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.0.5 |
| Published | 2017-02-28 |
| First published | 2017-02-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jason Brodie |
| Maintainers | jason0518 |

## Links

- npm: https://www.npmjs.com/package/gulp-mocha-docker
- Repository: https://github.com/idavatars-engineering/gulp-mocha-docker
- Homepage: https://github.com/idavatars-engineering/gulp-mocha-docker#readme
- Issues: https://github.com/idavatars-engineering/gulp-mocha-docker/issues
- npm.io page: https://npm.io/package/gulp-mocha-docker

## Dependencies (4)

- [yargs](https://npm.io/package/yargs.md) ^6.6.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.8.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.7

## Recent versions

- 1.0.5 (latest) — 2017-02-28
- 1.0.4 — 2017-02-28
- 1.0.3 — 2017-02-28
- 1.0.2 — 2017-02-28
- 1.0.1 — 2017-02-28
- 1.0.0 — 2017-02-14

## README

# What is this?
This little [Gulp](http://gulpjs.com) plugin is used to run [Mocha](http://mochajs.org/) tests within a RUNNING [Docker](https://docker.com/) Container. It allows you to pass in Mocha CLI args to the test scripts. More on that later...

# Installation
Simple: `npm i -S gulp-mocha-docker`

# Docker Setup
You must have a local `docker-compose.yaml` file properly setup. This plugin will look inside that file for the container name. See this example:
```yaml
version: "2"
services:
  web:
    container_name: my-api
    build:
      context: .
      dockerfile: Dockerfile-dev
    environment:
      NODE_ENV: development
    volumes:
      - ./:/usr/src/app
      - /usr/src/app/node_modules
    ports:
      - "8080:8080"
    command: node index.js
```
The plugin will look for a RUNNING container named `my-api` and then call the Docker CLI to run the mocha script inside your container. We assume you have mocha and your tests available in your container using normal Mocha "defaults".

# Gulp setup
Setup your gulp file like:
```js
var gulp    = require('gulp'),
gutil       = require('gulp-util'),
mocha       = require('gulp-mocha-docker');

gulp.task('test', function() {
    return mocha().catch(err => gutil.log(gutil.colors.red(err)));
});

gulp.task('default', ['test']);
```

# Usage
When you run `gulp` (shown if setup like the above) you should see the script attempting to run test inside your running Docker container. You can also pass in CLI args to Mocha like these examples:
- Run a specific test file: `gulp test --test './test/my-test.js'` or `gulp test -t './test/my-test.js'`
- Grep tests to run: `gulp test -g 'super-awesome-test'`
- Set the slow test threshold: `gulp test -s 200`

... If you refer to the [Mocha Usage Docs](https://mochajs.org/#usage) you can see other CLI args you can pass in! How slick is that

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