Skip to content

Instantly share code, notes, and snippets.

@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.
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 / 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');
});
});
});
@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 / disable-jquery-animations.js
Created March 30, 2016 21:15
Turn off jQuery animations
$.fx.off = true;
@fotinakis
fotinakis / README.md
Last active April 20, 2019 19:39
Fix Ember test timeouts on Circle CI

(See upstream testem PR: testem/testem#819)

Since around 2012, WebKit and other browsers have throttled timers (like setTimeout) to only a max of once per second in inactive tabs.

For some test suites, this may never be an issue. But, for example, in a very large Ember test suite with >1000 acceptance tests and much custom code, it manifested as often flaky and non-deterministic test timeouts, even in headless CI environments with Chrome in xvfb.

This has caused much much testing pain that might manifest as the not-obviously-related error: Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.

@fotinakis
fotinakis / .gitignore_global
Last active April 5, 2016 23:40
Git config
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
@fotinakis
fotinakis / freeze-css-animations.css
Last active April 1, 2016 00:25
Stop transitions and animations
*, *::before, *::after {
-moz-transition: none !important;
transition: none !important;
-moz-animation: none !important;
animation: none !important;
}
@fotinakis
fotinakis / feature_spec_with_animation.rb
Created September 23, 2015 15:53
Percy wait_for_animation for JavaScript animations
RSpec.feature :homepage, js: true do
def finished_all_animations?
page.evaluate_script('$(":animated").length') == 0
end
def wait_for_animation
Timeout.timeout(Capybara.default_wait_time) do
sleep 0.1 until finished_all_animations?
end
end
@fotinakis
fotinakis / _mdl_accordion.sass
Created September 11, 2015 21:55
(Material Design Light) MDL Accordion
// From @nickretallack - http://nickretallack.com/experiments/mdl/collapse/index.html
.mdl-accordion.mdl-accordion--opened
border-top: 1px solid #e0e0e0
border-bottom: 1px solid #e0e0e0
margin-top: -1px
.mdl-accordion.mdl-accordion--opened + .mdl-accordion.mdl-accordion--opened
border-top: none
margin-top: 0