{"id":13895741,"url":"https://github.com/leafo/lapis-spec-screenshot","last_synced_at":"2025-10-16T08:56:09.590Z","repository":{"id":66222847,"uuid":"70893290","full_name":"leafo/lapis-spec-screenshot","owner":"leafo","description":"A busted screenshot handler that takes images of your pages when testing","archived":false,"fork":false,"pushed_at":"2021-02-28T21:12:22.000Z","size":4,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-12T20:17:46.615Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","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/leafo.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":"2016-10-14T09:06:31.000Z","updated_at":"2024-02-16T00:05:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"15574132-ae5b-40a6-bef8-7460d1d1e600","html_url":"https://github.com/leafo/lapis-spec-screenshot","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/leafo/lapis-spec-screenshot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Flapis-spec-screenshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Flapis-spec-screenshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Flapis-spec-screenshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Flapis-spec-screenshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafo","download_url":"https://codeload.github.com/leafo/lapis-spec-screenshot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafo%2Flapis-spec-screenshot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279170964,"owners_count":26118665,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-06T18:02:26.413Z","updated_at":"2025-10-16T08:56:09.545Z","avatar_url":"https://github.com/leafo.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"\n# lapis-spec-screenshot\n\n`lapis-spec-screenshot` provides a\n[busted](https://github.com/Olivine-Labs/busted) output handler that, in\naddition to rendering the normal output, listens for special Lapis `screenshot`\nevents. Upon being notified, it will use `wkhtmltoimage` to screenshot the\ncurrent spec server at the specified URL.\n\nThis tool can be used to help discover visual regressions on your webpage by\ngiving you screenshots for each test request to view. (Further automation can\nbe done as you see fit)\n\n\u003e [wkhtmltoimage](http://wkhtmltopdf.org/) must be installed on your system for\n\u003e this library to work. Consult your package manager.\n\n## Install\n\n```bash\nluarocks install\n```\n\n## Usage\n\nWhen running `busted`, pass the module name for the screenshot output handler:\n\n```bash\nbusted -o \"lapis.spec.screenshot\"\n```\n\nThe tests will now listen to `screenshot` and `html` events.\n\n* `screenshot` - takes a URL to request. Saves a snapshot to the screenshot directory (default `spec/screenshots`)\n* `html` - takes HTML to render\n\nThe name of the image written is calculated by the full name of the test\n(including any wrapping describes)\n\nYou can then provide an alternate implementation of `request`\n\n```lua\n-- spec/helpers.lua\nlocal server = require \"lapis.spec.server\"\n\nlocal function request(url, opts)\n  local out = { server.request url, opts, ... }\n  local opts = opts or {}\n\n  local busted = require \"busted\"\n\n  if out[1] == 200 and not opts.post and out[3].content_type == \"text/html\" then\n    busted.publish({\"lapis\", \"screenshot\"}, url, opts, ...)\n  end\n\n  return unpack(out)\nend\n\nreturn { request = request }\n```\n\nUse this in place of the regular request method to automatically take a\nscreenshot on every 200 request that returns HTML.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafo%2Flapis-spec-screenshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafo%2Flapis-spec-screenshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafo%2Flapis-spec-screenshot/lists"}