{"id":15660228,"url":"https://github.com/ertrzyiks/hexo-test-utils","last_synced_at":"2025-05-05T20:11:44.881Z","repository":{"id":45186547,"uuid":"125268033","full_name":"ertrzyiks/hexo-test-utils","owner":"ertrzyiks","description":"A set of utils for easy testing Hexo plugins","archived":false,"fork":false,"pushed_at":"2023-02-03T02:46:41.000Z","size":774,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T20:11:35.314Z","etag":null,"topics":["hexo","sandbox","specs","testing"],"latest_commit_sha":null,"homepage":"https://ertrzyiks.github.io/hexo-test-utils/","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/ertrzyiks.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-14T20:10:43.000Z","updated_at":"2024-08-14T14:44:34.000Z","dependencies_parsed_at":"2023-02-18T02:45:34.918Z","dependency_job_id":null,"html_url":"https://github.com/ertrzyiks/hexo-test-utils","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertrzyiks%2Fhexo-test-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertrzyiks%2Fhexo-test-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertrzyiks%2Fhexo-test-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ertrzyiks%2Fhexo-test-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ertrzyiks","download_url":"https://codeload.github.com/ertrzyiks/hexo-test-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252569645,"owners_count":21769517,"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":["hexo","sandbox","specs","testing"],"created_at":"2024-10-03T13:20:41.670Z","updated_at":"2025-05-05T20:11:44.865Z","avatar_url":"https://github.com/ertrzyiks.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hexo-test-utils\n[![Build Status](https://travis-ci.org/ertrzyiks/hexo-test-utils.svg?branch=master)](https://travis-ci.org/ertrzyiks/hexo-test-utils)\n\n[Hexo](https://github.com/hexojs/hexo) is quite easy to write tests for, but the needed boilerplate code can be a barrier.\nThis packages provides a set of utils to simplify testing Hexo plugins.\n\nOffered features:\n - Sandbox environment\n - high level functions for Hexo internals\n - ECMAScript5 compatibility\n\n## Installation\n\n```\nnpm install hexo-test-utils\n```\n\n## Sandbox\n\nThe main feature is a Sandbox. It allows to create an isolated environment of Hexo blog. Combined\nwith a fixture, it's easy to prepare all need files, process the blog and assert the output.\n\nTo create a Sandbox instance, first you need to create a factory with `createSandbox`:\n\n```js\nconst {createSandbox} = require('hexo-test-utils')\nconst Hexo = require('hexo')\nconst path = require('path')\n\nconst sandbox = createSandbox(Hexo, {\n  fixture_folder: path.join(__dirname, '..', 'fixtures'),\n  plugins: [\n    path.join(__dirname, '..', 'src')\n  ]\n})\n```\n\nNow, the `sandbox` is a function which returns a new context - an instance of Hexo blog which is ready for processing.\n\n### Using fixture folder\nIf `fixture_folder` is set, the factory function accepts one parameter, name of the fixture folder where live all fixture files.\n\nTo prepare a fixture with one post, create folder `./fixtures/one-post/source/_posts/` and put the markdown file there.\n\n```js\nconst context = sandbox('one-post')\n```\n\nAt this moment, the Hexo blog is created, but no files are loaded. To start the loading process, call `process` method.\n\n```\nconst {process} = require('hexo-test-utils/core')\n\nprocess(context).then(() =\u003e {\n  // Hexo processed the ./fixtures/one-post/ folder as a blog\n})\n```\n\nNow you can start check the behavior of your plugin.\n\n\u003e Note: no files were actually saved on the hard drive, all the process happened in memory.\n\n### Empty Sandbox\n\nYou can skip `fixture_folder` if you don't need any files to exists, for example when testing a view helper in isolation.\nThe factory function will have no parameters then and the Sandbox will be an empty Hexo project - no posts, no theme, no assets.\n\nYou can still use Hexo API to provide fixtures programmatically.\n\n## Documentation\n\nRead API documentation [here](https://ertrzyiks.github.io/hexo-test-utils/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fertrzyiks%2Fhexo-test-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fertrzyiks%2Fhexo-test-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fertrzyiks%2Fhexo-test-utils/lists"}