# yeoman-assert

> Assert utility from yeoman

Latest version **3.1.1** (published 2018-03-25) · BSD-2-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install yeoman-assert
pnpm add yeoman-assert
yarn add yeoman-assert
bun add yeoman-assert
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.1.1 |
| Published | 2018-03-25 |
| First published | 2014-11-16 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | separate (@types/yeoman-assert) |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51 |
| Author | Yeoman team |
| Maintainers | addyosmani, arthurvr, eddiemonge, hemanth, mischah, sboudrias, sindresorhus, stefanbuck, zckrs |
| Keywords | assert, assertion, test, testing, utility, helper, yeoman |

## Links

- npm: https://www.npmjs.com/package/yeoman-assert
- Repository: https://github.com/yeoman/yeoman-assert
- Homepage: http://yeoman.io
- Issues: https://github.com/yeoman/yeoman-assert/issues
- npm.io page: https://npm.io/package/yeoman-assert

## 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

- 3.1.1 (latest) — 2018-03-25
- 3.1.0 — 2017-09-24
- 3.0.0 — 2017-02-11
- 2.2.3 — 2017-02-11
- 2.2.2 — 2016-12-14
- 2.2.1 — 2016-04-20
- 2.2.0 — 2016-04-17
- 2.1.2 — 2016-03-31
- 2.1.1 — 2015-12-08
- 2.1.0 — 2015-09-06
- 2.0.0 — 2015-04-08
- 1.0.0 — 2014-11-16

## README

# yeoman-assert [![Build Status](https://travis-ci.org/yeoman/yeoman-assert.svg?branch=master)](https://travis-ci.org/yeoman/yeoman-assert)

`yeoman-assert` is extending the native Node.js `assert` module. Every methods in `assert` also is available with `yeoman-assert`, plus some code scaffolding related assertion helpers.


## Install

```
$ npm install yeoman-assert
```


## Usage

```js
const assert = require('yeoman-assert');

assert(true);
assert.equal(1, 1);
```


## API

### `assert.file()`

- **path** (String|Array) Path to a file.

Assert that a file exists.

```js
assert.file('templates/user.hbs');
```

Assert that each files in the array exists.

```js
assert.file(['templates/user.hbs', 'templates/user/edit.hbs']);

```


### `assert.noFile()`

- **path** (String|Array) Path to a file.

Assert that a file doesn't exists.

```js
assert.noFile('templates/user.hbs');
```

Assert that each of an array of files doesn't exist.

```js
assert.noFile(['templates/user.hbs', 'templates/user/edit.hbs']);

```


### `assert.fileContent()`

- **file** (String|Array) Path to a file.
- **reg** (Regex|String) Regex or string that will be used to search the file.

Assert that a file's content matches a string.

```js
assert.fileContent('models/user.js', 'App.User = DS.Model.extend');

```

Assert that a file's content matches a regex.

```js
assert.fileContent('models/user.js', /App\.User = DS\.Model\.extend/);
```

Assert that each of an array of files content matches a regex or string.

```js
assert.fileContent([
   ['models/user.js', 'App.User = DS.Model.extend'],
   ['controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/]
]);
```


### `assert.noFileContent()`

- **file** (String|Array) Path to a file.
- **reg** (Regex|String) Regex or string that will be used to search the file.

Assert that a file's content does not match a string.

```js
assert.noFileContent('models/user.js', 'App.User = DS.Model.extend');

```

Assert that a file's content does not match a regex.

```js
assert.noFileContent('models/user.js', /App\.User = DS\.Model\.extend/);
```

Assert that each of an array of files content does not match a regex or string.

```js
assert.noFileContent([
   ['models/user.js', 'App.User = DS.Model.extend'],
   ['controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/]
]);
```

### `assert.textEqual()`

- **value** (String) A string.
- **expected** (String) The expected value of the string.

Assert that two strings are equal after standardization of newlines.

```js
assert.textEqual('I have a yellow cat', 'I have a yellow cat');
```


### `assert.implement()`

- **subject** (Object) Subject implementing the façade.
- **methods** (Object|Array) A façace, hash or array of keys to be implemented.

Assert an Object implements an interface.

```js
assert.implement(fs, ['readFile']);
```


### `assert.notImplement()`

- **subject** (Object) Subject not implementing the methods.
- **methods** (Object|Array) Hash or array of method names to be implemented.

Assert an Object doesn't implements any method of an interface.

```js
assert.notImplement(fs, ['foo']);
```

### `assert.objectContent()`

Assert an object contains at least a set of keys

```js
var anObject = {a: 1};

assert.objectContent(anObject, {a: 2});
```

### `assert.noObjectContent()`

Assert an object does not contain at least a set of keys

```js
var anObject = {a: 1};

assert.noObjectContent(anObject, {a: 1});
```

### `assert.jsonFileContent()`

Assert a JSON file contains at least a set of keys (rely of `assert.objectContent()`)

```js
assert.jsonFileContent('path/to/file.json', {a: 2});
```

### `assert.noJsonFileContent()`

Assert a JSON file does not contain at least a set of keys (rely of `assert.noObjectContent()`)

```js
assert.noJsonFileContent('path/to/file.json', {a: 1});
```


## Contribute

See the [contributing docs](http://yeoman.io/contributing/).


## License

BSD-2-Clause © Google

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