percy-capybara-bedrock
- Goal
- Minimum Requirements
- Installation
- Usage
- FAQ
- Does it support Sage?
- Is it a must to use Sage?
- It looks awesome. Where can I find some more goodies like this?
- This isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?
- Feedback
- Security
- Change log
- Credits
- License
- Releasing
Goal
The official Percy Anywhere uploads all static files (resources) under assets_dir
. This breaks when taking snapshots on a Bedrock project because of the resource limit (15,000 files).
percy-capybara-bedrock
fixes the issue by defining a custom loader which:
- looks for static files under certain directories only
- excludes certain directories, e.g:
.git
,vendor
andnode_modules
- excludes certain file extensions, e.g:
.php
and.sql
Minimum Requirements
- Percy account
- Ruby 2.6.1
- PhantomJS
- Bedrock v1.12.0
- (Optional) Sage v9.0.0
Installation
$ bundle add percy-capybara-bedrock
Under the hood, percy-capybara-bedrock
uses Poltergeist (a driver for Capybara) which requires PhantomJS. Follow the instructions at: https://github.com/teampoltergeist/poltergeist#installing-phantomjs
Usage
Create a percy.rb
file under bedrock project root:
require "percy/capybara/bedrock/anywhere"
# URL pointing to the local or remote host
server = "http://localhost:8080"
# Absolute path to a web root directory
web_root = File.expand_path("../web/", __FILE__)
# Path where your webserver hosts the WordPress site
assets_base_url = "/"
Percy::Capybara::Bedrock::Anywhere.run(server, web_root, assets_base_url) do|page|
# Basic
page.visit("/")
Percy::Capybara.snapshot(page, name:"/")
# Allow Javascript execution to finish
page.visit("/about-us/")
sleep(1)
Percy::Capybara.snapshot(page, name:"/about-us/")
# Capybara DSL
# More at: https://github.com/teamcapybara/capybara#the-dsl
page.visit("/contact-us")
fill_in("Name", with: "Tang Rufus")
fill_in("Message", with: "Testing contact form submission")
click_button('Send')
sleep(1) # Wait for thank you page to show up
Percy::Capybara.snapshot(page, name:"/contact-us/thank-you/")
end
Given that your WordPress site is running at http://localhost:8080, take percy snapshots:
$ PERCY_TOKEN=my-secret-token PERCY_BRANCH=local PERCY_DEBUG=1 bundle exec ruby percy.rb
FAQ
Does it support Sage?
Yes, run $ yarn build:production
before snapshot.
Is it a must to use Sage?
No, Sage is optional.
It looks awesome. Where can I find some more goodies like this?
- Articles on Itineris' blog
- More projects on Itineris' GitHub profile
- More plugins on Itineris' wp.org profile
- Follow @itineris_ltd and @TangRufus on Twitter
- Hire Itineris to build your next awesome site
This isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?
Thanks! Glad you like it. It's important to let my boss knows somebody is using this project. Instead of giving reviews on wp.org, consider:
- tweet something good with mentioning @itineris_ltd and @TangRufus
- star this Github repo
- watch this Github repo
- write blog posts
- submit pull requests
- hire Itineris
Feedback
Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.
Security
If you discover any security related issues, please email hello@itineris.co.uk instead of using the issue tracker.
Change log
Please see CHANGELOG for more information on what has changed recently.
Credits
percy-capybara-bedrock is a Itineris Limited project created by Tang Rufus.
Full list of contributors can be found here.
License
percy-capybara-bedrock is released under the MIT License.
Releasing
For maintainers only
$ gem install github_changelog_generator
$ gem install gem-release
$ git checkout -b version-bump
$ gem bump --sign --tag --release --version patch --pretend
git push --tags && \
github_changelog_generator && \
npx doctoc README.md && \
git add CHANGELOG.md README.md && \
git commit -m "github_changelog_generator && npx doctoc README.md" && \
git push origin version-bump && \
hub pull-request