{"id":16485385,"url":"https://github.com/morganconrad/metalsmith-assert","last_synced_at":"2025-04-04T17:49:16.747Z","repository":{"id":13882021,"uuid":"74927391","full_name":"MorganConrad/metalsmith-assert","owner":"MorganConrad","description":"Metalsmith plugin for testing with Node's assert module.","archived":false,"fork":false,"pushed_at":"2023-01-07T08:24:47.000Z","size":177,"stargazers_count":1,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T08:49:26.580Z","etag":null,"topics":["assertions","metalsmith","metalsmith-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MorganConrad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-28T01:53:17.000Z","updated_at":"2021-10-01T00:23:30.000Z","dependencies_parsed_at":"2023-01-13T17:39:52.534Z","dependency_job_id":null,"html_url":"https://github.com/MorganConrad/metalsmith-assert","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Fmetalsmith-assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Fmetalsmith-assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Fmetalsmith-assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Fmetalsmith-assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MorganConrad","download_url":"https://codeload.github.com/MorganConrad/metalsmith-assert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226195,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","metalsmith","metalsmith-plugin"],"created_at":"2024-10-11T13:25:44.493Z","updated_at":"2025-04-04T17:49:16.733Z","avatar_url":"https://github.com/MorganConrad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://secure.travis-ci.org/MorganConrad/metalsmith-assert.png)](http://travis-ci.org/MorganConrad/metalsmith-assert)\n[![License](http://img.shields.io/badge/license-MIT-A31F34.svg)](https://github.com/MorganConrad/metalsmith-assert)\n[![NPM Downloads](http://img.shields.io/npm/dm/metalsmith-assert.svg)](https://www.npmjs.org/package/metalsmith-assert)\n[![Known Vulnerabilities](https://snyk.io/test/github/morganconrad/metalsmith-assert/badge.svg)](https://snyk.io/test/github/morganconrad/metalsmith-assert)\n[![Coverage Status](https://coveralls.io/repos/github/MorganConrad/metalsmith-assert/badge.svg)](https://coveralls.io/github/MorganConrad/metalsmith-assert)\n\n# metalsmith-assert\nA [Metalsmith](http://www.metalsmith.io/) plugin for testing the file objects with Node's [assert](https://nodejs.org/api/assert.html) module.  \n\n### Usage\n\nInstall as usual,  `npm install metalsmith-assert`.\n\nJavascript:  `use(metalsmith-assert(assertions, options))`\n\nCLI: You'll lose a few options since it can't support functions.\n\nBy default, **metalsmith-assert** will console.log all AssertionErrors and a summary line.\nIt then calls `done(error)` with the last AssertionError (if any) or `null` if all is well.\n\n#### Assertions\n\n**assertions** should be an object containing objects of the following format:\n\n    testname : {  // used for the message\n      assert:     // which method of assert to call, default -\u003e \"ok\".  See below.\n      actual:     // if a string, the use fileData[actual],\n                  // special case: if '.', use fileData.contents.toString()\n                  // else call actual(fileData, filePath, metalsmith)\n      expected:   // if a string use it\n                  // else call expected(fileData, filePath, metalsmith)\n                  // note: this field is ignored if assert is \"ok\"\n    }\n\n##### Legal values for assert method are all methods from [assert](https://nodejs.org/api/assert.html) that take \"actual\" as the first argument.\n\n - deepEqual(actual, expected, ...)\n - deepStrictEqual(actual, expected, ...)\n - equal(actual, expected, ...)\n - notDeepEqual(actual, expected, ...)\n - notDeepStrictEqual(actual, expected, ...)\n - notEqual(actual, expected, ...)\n - notStrictEqual(actual, expected, ...)\n - ok(actual, ...) (the default method)\n - strictEqual(actual, expected, ...)\n\n**Be precise in your spelling and capitalization.**  You can also use an array of objects, in which case the testname will be the less informative \"test N\".\n\n\n#### Options (all default to null/false)\n\n**options.quiet**  Don't log individual failures, nor the summary of passed/failed.\n\n**options.continueBuildOnError** Always call `done(null)` even if there was a failure.\n\n - If you enable _both_ quiet and continueBuildOnError this module is useless.  :-)\n\n**options.disable** a quick way to turn metalsmith-assert off - it will immediately call done().\n\n**options.fileFilter** determines which files will be included\n - if missing, include all files.\n - if a string or Regex, only include matching filePaths.\n - if a user-provided-function, include the file when `filter(filePath, data, metalsmith)` returns true.  \n _e.g._ If you want to use [multimatch](https://www.npmjs.com/package/multimatch), pass something like `function(filePath) { return multimatch([filePath], [\"blogs/**\", ...])[0] };`\n\n\n### Examples\n\nTo verify that every file has a title, has a tag === \"vacation\", and the img is a svg file\n\n    .use(metalsmith-assert({\n          \"title exists\" : { actual: \"title\"},\n          \"tag === vacation\" : { assert: \"equal\", actual: \"tag\", expected: \"vacation\" },\n          \"image is svg\" : { actual: function(data) { return /\\.svg$/.test(data.img); }\n        } ) )\n\n\n\n### Notes, Todos, and Caveats\n\nBe precise in your spelling and capitalization!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorganconrad%2Fmetalsmith-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorganconrad%2Fmetalsmith-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorganconrad%2Fmetalsmith-assert/lists"}