{"id":16237578,"url":"https://github.com/vowstar/honkit-tester","last_synced_at":"2025-03-19T15:31:16.292Z","repository":{"id":42084093,"uuid":"307343157","full_name":"vowstar/honkit-tester","owner":"vowstar","description":"Tester for honkit plugins","archived":false,"fork":false,"pushed_at":"2024-10-28T13:29:21.000Z","size":920,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T19:38:25.910Z","etag":null,"topics":["honkit"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vowstar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-26T10:59:00.000Z","updated_at":"2024-10-28T13:25:52.000Z","dependencies_parsed_at":"2022-08-12T04:50:12.422Z","dependency_job_id":"a0a8c520-199b-4734-8a06-0c569c7d5e10","html_url":"https://github.com/vowstar/honkit-tester","commit_stats":{"total_commits":123,"total_committers":7,"mean_commits":"17.571428571428573","dds":0.5040650406504066,"last_synced_commit":"bc9c4bb5e8e6683df3a19a9703441a736706984e"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vowstar%2Fhonkit-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vowstar%2Fhonkit-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vowstar%2Fhonkit-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vowstar%2Fhonkit-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vowstar","download_url":"https://codeload.github.com/vowstar/honkit-tester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244003435,"owners_count":20382189,"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":["honkit"],"created_at":"2024-10-10T13:36:12.362Z","updated_at":"2025-03-19T15:31:15.966Z","avatar_url":"https://github.com/vowstar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Honkit integration tests framework\n\n[![Build Status](https://github.com/vowstar/honkit-tester/actions/workflows/test.yml/badge.svg)](https://github.com/vowstar/honkit-tester/actions)\n[![Coverage Status](https://coveralls.io/repos/github/vowstar/honkit-tester/badge.svg?branch=master)](https://coveralls.io/github/vowstar/honkit-tester?branch=master)\n[![NPM Version](https://badge.fury.io/js/honkit-tester.svg)](https://badge.fury.io/js/honkit-tester)\n[![NPM Downloads](https://img.shields.io/npm/dm/honkit-tester.svg?style=flat)](https://www.npmjs.org/package/honkit-tester)\n\nThis is a fork of [gitbook-tester(https://github.com/todvora/gitbook-tester)](https://github.com/todvora/gitbook-tester), port to honkit.\n\nNo more mocking of ```npx honkit build```! Verify your honkit-plugin against a real, up-to-date\nversion of honkit. This integration framework creates a temporary book, attaches your local honkit plugin, runs ```npx honkit build``` and returns the parsed pages content.\n\nAll the book resources are generated and executed in a temporary directory (exact location\n  depends on your operating system). Resources are cleaned up upon test phase.\n\n## Usage\n\n```js\nvar tester = require('honkit-tester');\ntester.builder()\n  .withContent('This text is {% em %}highlighted!{% endem %}')\n  .withBookJson({\"plugins\": [\"emphasize\"]})\n  .create()\n  .then(function(result) {\n    // do something with results!\n    console.log(result[0].content);\n  });\n```\n\nExpected output is then:\n\n```html\n\u003cp\u003eThis text is \u003cspan class=\"pg-emphasize pg-emphasize-yellow\" style\u003ehighlighted !\u003c/span\u003e\u003c/p\u003e\n```\n\nOnly the ```\u003csection\u003e``` content of generated pages is currently returned. Do you need\nto test navigation, the header of page, etc.? Let me know or send me a pull request.\n\nhonkit-tester package provides a single entry point:\n\n```js\ntester.builder()\n```\n\nOn the builder, the following methods can be called:\n\n### .withContent(markdownString)\n\nPut some **Markdown** content into the generated book's README.md (initial/intro page).\n\n### .withPage(pageName, pageContent[, level])\n\nAdd another book page. For example:\n\n```js\n  .withPage('second', 'Second page content')\n```\n\nThere is no need for specifying extensions, ```.md``` will be automatically added.\nThe rendered page can be accessed later in tests. For example:\n\n```js\nvar cheerio = require('cheerio');\n\nit('should add second book page', function(testDone) {\n    tester.builder()\n    .withContent('First page content')\n    .withPage('second', 'Second page content')\n    .create()\n    .then(function(result) {\n      expect(result.get('second.html').content).toEqual(cheerio.load('\u003cp\u003eSecond page content\u003c/p\u003e')('body').html().trim());\n    })\n    .fin(testDone)\n    .done();\n});\n```\n\n**Level**: how nested should be this page, optional parameter. ```0``` for top level page, ```1``` for second, ```2``` for third...\n\n### .withBookJson(jsObject)\n\nPut your own ```book.json``` content as a JS object. May contain plugins,\nthe plugin configuration or anything valid as described in the [official documentation](http://help.gitbook.com/format/configuration.html).\nCan also be omitted.\n\n### .withLocalPlugin(path)\n\nAttach currently tested or developed plugin to the generated gitbook files. All locally attached plugins will be automatically added\n to ```book.json``` in the ```plugins``` section.\n\nShould be called\nusing the following format:\n\n```js\n.withLocalPlugin('/some/path/to/module')\n```\n\nIf you run your tests from the dir ```spec``` of your plugin, you should provide the\npath to the root of your plugin module. For example:\n\n```js\n.withLocalPlugin(require('path').join(__dirname, '..'))\n```\n\n### .withLocalDir(path)\n\nArrach a user assert dir to the generated gitbook files. This assert dir will\nsymbolic linked to book dir, and must in the project directory.\n\nShould be called\nusing the following format:\n\n```js\n.withLocalDir(path.join(__dirname, '..', 'assert_dir'))\n```\n\n### .withFile(path, content)\n\nAllows you to create a file inside the book directory. Just provide the path for the file and string content. For example:\n\n```js\n.withFile('includes/test.md', 'included from an external file!')\n```\n\nThen you can use the file however you would like in your plugin or simply include its content in a page. For example:\n\n```markdown\n'This text is {% include \"./includes/test.md\" %}'\n```\n\n### .create()\n\nStart a build of the book. Generates all the book resources, installs required\nplugins, attaches the provided local modules. Returns ```promise```.\n\n## Working with results\n\n```js\n.then(function(result) {\n  var index = result.get('index.html');\n  console.log(index);  \n})\n```\n\nshould output JavaScript object like\n\n```js\n{ path: 'index.html',\n  '$': [cheerio representation of the page]\n  content: '\u003ch1 id=\"test-me\"\u003etest me\u003c/h1\u003e' }\n\n```\n\n## Debugging\n\nIf you wish to see detailed output of the build and the gitbook logs, provide the ENV variable ``DEBUG=true``.\n\n## Complete test example\n\nHow to write a simple test, using node-jasmine.\n\n```js\n\nvar tester = require('honkit-tester');\nvar cheerio = require('cheerio');\n\n// set timeout of jasmine async test. Default is 5000ms. That can\n// be too low for a complete test (install, build, expects)\njasmine.getEnv().defaultTimeoutInterval = 20000;\n\ndescribe(\"my first honkit integration test\", function() {\n  it('should create book and parse content', function(testDone) {\n    tester.builder()\n    .withContent('#test me \\n\\n![preview](preview.jpg)')\n    .create()\n    .then(function(result) {\n      expect(result[0].content).toEqual(cheerio.load('\u003ch1 id=\"test-me\"\u003etest me\u003c/h1\u003e\\n\u003cp\u003e\u003cimg src=\"preview.jpg\" alt=\"preview\"\u003e\u003c/p\u003e')('body').html().trim());\n    })\n    .fin(testDone)\n    .done();\n  });\n});\n```\n\n## License\n\nThis project is available under [Apache-2.0](http://choosealicense.com/licenses/apache-2.0/) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvowstar%2Fhonkit-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvowstar%2Fhonkit-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvowstar%2Fhonkit-tester/lists"}