Skip to content

Instantly share code, notes, and snippets.

View klamping's full-sized avatar

Kevin Lamping klamping

View GitHub Profile
@klamping
klamping / wdio.conf.js
Created October 17, 2015 14:31
Start selenium-standalone via wdio.conf.js
/*global browser:false*/
var selenium = require("selenium-standalone");
var Promise = require("bluebird");
exports.config = {
// Other configs go here
//
// =====
// Hooks
@klamping
klamping / git.md
Created October 24, 2015 01:45
Git usage for visual regression test images

Storing Baseline Images

Images are stored in the Git repo like any other file. This makes is simple to share baseline images across the teams. It also allows for changes in the baseline to be tracked over time.

Accepting/Rejecting changes

Whether or not updates to the baseline images are accepted depends on the goal of the changes. Here are a few scenarios:

No visual changes

@klamping
klamping / examples.js
Created November 9, 2015 18:05
Template String Examples
https://www.npmjs.com/package/es6-template-strings
userCity:{name: "UserCity", selector:"//input[@ng-model='${selector1}']/${selector2}", isTextEntry:true},
browser.addCommand(commandPrePend + "_" + commandEntry.name + "_setValue" , function(textValue, selectors) {
var selector = templatE(commandEntry.selector, selectors);
@klamping
klamping / compareScreen.js
Last active November 13, 2015 19:58
WebdriverCSS Assertion Util
var expect = require("chai").expect;
var _ = require("lodash");
var checkMismatch = function(err, res) {
expect(err).to.not.exist;
_.forOwn(res, function(elementShots) {
elementShots.forEach(function(shot) {
expect(shot.isWithinMisMatchTolerance).to.equal(true, "'" + shot.properties.name + "' visual " + shot.message);
});
@klamping
klamping / 1_before.json
Last active December 24, 2015 20:01
Need to transform a collection with array values in to an array of all the variations possible from those arrays.
[{
"browser": "ie",
"browser_version": ["11.0", "10.0"],
"os_version": ["10", "8.1"]
}]
@klamping
klamping / assertShots.js
Last active February 26, 2016 20:33
assertShots WebdriverCSS Assertion
// @see https://github.com/webdriverio/webdrivercss/issues/103
var assert = require("assert");
function assertShots (err, shots) {
assert.ifError(err);
Object.keys(shots).forEach(function(element) {
shots[element].forEach(function(shot) {
assert.ok(shot.isWithinMisMatchTolerance, shot.message);
})
@klamping
klamping / startNewSession.js
Created February 23, 2016 17:00
wdio -> browserstack session info
/**
* Resets the browser for the next set of tests and sets the test name
* for Browserstack organization
*
* @param {object} mochaTest The Mocha 'test' object (should be `this` in your tests)
* @param {object} [viewportSize]
* @param {number} [viewportSize.width] - Viewport width; defaults to 1280
* @param {number} [viewportSize.height] - Viewport height, defaults to 960
* @example
* browser.startNewSession(this);
@klamping
klamping / willFail.js
Last active March 26, 2016 14:15
synchronous code fails with .only
var chai = require('chai');
var expect = chai.expect;
describe('Landing Page', function() {
beforeEach(function () {
browser.url('http://webdriver.io.s3-website-eu-west-1.amazonaws.com/');
});
it.only('should have the right title', function () {
var title = browser.getTitle();
@klamping
klamping / wdio.conf.js
Created June 10, 2016 02:13
Hook and retries
module.exports = {
//
// Framework to run your tests with.
framework: "mocha",
//
// Options to be passed to Mocha.
// See the full list at http://mochajs.org/
mochaOpts: {
ui: "bdd",
timeout: 270000,
@klamping
klamping / proposal.md
Last active June 27, 2016 14:27
Automated UI Testing Proposal

Talk Title: We need a better way to test

Description:

Testing can be a real pain! Isn't it good enough that it looks fine in Chrome? Should I really have to test the login page for a change to the contact form?

As a front-end dev, I've lazily assumed that testing is the realm of QA. Sure, I'll begrudgingly check my site in IE to see how much repair it needs, but I confess to cutting corners when testing and saying "That shouldn't break anything..."

This worked okay while I was building small sites, but now that I'm working with multiple teams on large projects, cutting corners doesn't work. The edge case always comes in to play and things that probably won't break do.