Caution
This repository is archived and no longer actively maintained.
We are no longer accepting issues, feature requests, or pull requests. For additional support or questions, please visit the Maintenance Reboot plan.
yeoman-assert is extending the native Node.js assert module. Every method in assert also is available with yeoman-assert, plus some code scaffolding related assertion helpers.
$ npm install yeoman-assert
const assert = require('yeoman-assert');
assert(true);
assert.equal(1, 1);- path (String|Array) Path to a file.
Assert that a file exists.
assert.file('templates/user.hbs');Assert that each file in the array exists.
assert.file(['templates/user.hbs', 'templates/user/edit.hbs']);- path (String|Array) Path to a file.
Assert that a file doesn't exist.
assert.noFile('templates/user.hbs');Assert that each of an array of files doesn't exist.
assert.noFile(['templates/user.hbs', 'templates/user/edit.hbs']);- 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.
assert.fileContent('models/user.js', 'App.User = DS.Model.extend');Assert that a file's content matches a regex.
assert.fileContent('models/user.js', /App\.User = DS\.Model\.extend/);Assert that each of an array of files content matches a regex or string.
assert.fileContent([
['models/user.js', 'App.User = DS.Model.extend'],
['controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/]
]);- 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.
assert.noFileContent('models/user.js', 'App.User = DS.Model.extend');Assert that a file's content does not match a regex.
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.
assert.noFileContent([
['models/user.js', 'App.User = DS.Model.extend'],
['controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/]
]);- value (String) A string.
- expected (String) The expected value of the string.
Assert that two strings are equal after standardization of newlines.
assert.textEqual('I have a yellow cat', 'I have a yellow cat');- subject (Object) Subject implementing the facade.
- methods (Object|Array) A facade, hash or array of keys to be implemented.
Assert an Object implements an interface.
assert.implement(fs, ['readFile']);- subject (Object) Subject not implementing the methods.
- methods (Object|Array) Hash or array of method names to be implemented.
Assert an Object doesn't implement any method of an interface.
assert.notImplement(fs, ['foo']);Assert an object contains at least a set of keys.
var anObject = {a: 1};
assert.objectContent(anObject, {a: 2});Assert an object does not contain at least a set of keys.
var anObject = {a: 1};
assert.noObjectContent(anObject, {a: 1});Assert a JSON file contains at least a set of keys (relies on assert.objectContent()).
assert.jsonFileContent('path/to/file.json', {a: 2});Assert a JSON file does not contain at least a set of keys (relies on assert.noObjectContent()).
assert.noJsonFileContent('path/to/file.json', {a: 1});See the contributing docs.
BSD-2-Clause © Google