Skip to content

Instantly share code, notes, and snippets.

@fotinakis
fotinakis / ember-acceptance-test.js
Last active July 11, 2016 21:08
ember-percy example 1
describe('Acceptance: Marketing pages', function() {
it('can visit /about', function() {
visit('/about');
click('.TeamMember:first');
andThen(() => {
expect(find('.TeamMember:first')).to.have.class('is-expanded');
});
});
});
describe('Acceptance: Marketing pages', function() {
it('can visit /about', function() {
visit('/about');
percySnapshot('about page');
click('.TeamMember:first');
andThen(() => { expect(find('.TeamMember:first')).to.have.class('is-expanded'); });
percySnapshot('about page (show details)');
});
@fotinakis
fotinakis / bash
Created September 30, 2016 18:17
List numbers of connection states with netstat
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n
@fotinakis
fotinakis / zoomTestContainer.js
Created November 29, 2016 19:20
Ember zoomTestContainer
$('#ember-testing-container').css('height', '100%');
$('#ember-testing-container').css('width', '100%');
$('#ember-testing').css('zoom', '100%');
@fotinakis
fotinakis / hide-text.js
Last active January 31, 2017 21:04
Pure JavaScript: Hide all text on the page but preserve element spacing.
function textNodesUnder(el){
var n, a = [];
var walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
while (n = walk.nextNode()) { a.push(n); }
return a;
}
// Normalize all text nodes (merge adjacent nodes).
var elements = document.getElementsByTagName('*');
for (var i = 0; i < elements.length; i++) {
@fotinakis
fotinakis / freeze-moment.js
Last active April 10, 2017 23:54
Ember freezeMoment test helper
import Ember from 'ember';
import {
beforeEach,
afterEach
} from 'mocha';
// Support for overriding the baseline time used by Moment.js. Accepts ISO formatted timestamps.
//
// Requires:
// moment >= 2.11.0 in order to override moment.now.
@fotinakis
fotinakis / native-loader-remote-example.rb
Created April 24, 2017 16:07
Percy native loader remote example
# Example to use Percy against a remote host.
# Requires: poltergeist gem, and phantomjs.
#
# This uses the percy-capybara native loader, which is slower and less accurate
# than other loaders. See:
# https://percy.io/docs/clients/ruby/capybara-other#non-rails-asset-setup
require 'percy/capybara'
require 'capybara/poltergeist'
@fotinakis
fotinakis / gist:ec5a304286738f7e8f401289f2d6b1d0
Last active May 17, 2017 17:44
percy-capybara manual parallelization setup
# Tell Percy that this is a parallelized build. Because we separately finalize
# Percy builds, this should remain "2" no matter the actual number of nodes.
#
# Set this environment variable:
PERCY_PARALLEL_TOTAL=2
# In your spec_helper, only call `initialize_build` and not finalize:
config.before(:suite) { Percy::Capybara.initialize_build }
# Do not call `finalize_build`.
@fotinakis
fotinakis / hide-flappy-elem.css
Last active June 18, 2017 21:42
Hide elements only in Percy renderer
/*
This is an example of how to add special CSS that only applies in Percy's
rendering environment, for example to hide certain dynamic elements.
This is a bit of hack, we don't guarantee this will work forever in Percy
and we'll be adding a more officially-supported mechanism for this.
*/
@-moz-document domain(proxyme.percy.io) {
#flappy-div {
visibility: hidden !important;
@fotinakis
fotinakis / percy_loader.rb
Created October 3, 2017 22:22
Custom Percy::Capybara SprocketsLoader that changes path
class CustomLoader < Percy::Capybara::Loaders::SprocketsLoader
def build_resources
super.map do |resource|
resource.resource_url = resource.resource_url.gsub('//localhost:3000/', '/')
end
end
end
Percy::Capybara.use_loader(CustomLoader)