Skip to content

Instantly share code, notes, and snippets.

View klamping's full-sized avatar

Kevin Lamping klamping

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / test.js
Created July 31, 2015 21:13
Gemini Screen Size
var gemini = require('gemini');
gemini.suite('my test', function(parent) {
parent.setUrl('/some/path')
.setCaptureElements('.selector1', '.selector2');
.capture('state', function (actions) {
actions.setWindowSize(1000, 1000);
});
});
@klamping
klamping / package.json
Created July 23, 2015 19:28
NPM preinstall for private registries behind VPNs
{
"name": "myApp",
"version": "1.0.0",
"scripts": {
"preinstall": "sh vpn-check.sh"
},
"dependencies": {
"moduleOnPrivateRepo": "1.0.0"
}
}