Skip to content

Instantly share code, notes, and snippets.

View senocular's full-sized avatar
:octocat:

Trevor McCauley senocular

:octocat:
View GitHub Profile
@senocular
senocular / Rename Tab
Last active December 26, 2015 08:09
JavaScript bookmark for renaming the current tab. Does not persist after page reloads, but can be helpful to manage existing tabs.
javascript: document.title = prompt("Rename Tab"); return false;
@senocular
senocular / BitmapData
Created November 12, 2013 16:56
Subset of AS BitmapData API in JS
function BitmapData(canvas){
this.canvas = canvas;
this.width = this.canvas.width;
this.height = this.canvas.height;
this.context = this.canvas.getContext("2d");
this.imageData = null;
// true if the canvas has been drawn into
// and the image data has not been updated
this.dataInvalid = false;
@senocular
senocular / log.js
Last active January 21, 2016 20:48
console.log('github', document.readyState)
document.addEventListener('DOMContentLoaded', function(){
console.log('github ready')
})
@senocular
senocular / step-through.js
Created April 18, 2016 14:50
Simple way to step through a code block with execution for demonstration purposes
class FunctionSequencer {
constructor (genFunc) {
if (Object.prototype.toString.call(genFunc) !== '[object GeneratorFunction]') {
throw new TypeError('Failed to create FunctionSequencer instance: parameter 1 is not of type \'GeneratorFunction\'.');
}
this._genFunc = genFunc;
this._codeBlocks = this._parseBlocks(this._genFunc);
alert('hi');
@senocular
senocular / nw_before_bug.md
Created October 31, 2016 20:12
Hooks before/beforeEach continues to running test(s) before their command queue is finished.

Hooks before/beforeEach continues to running test(s) before their command queue is finished.

When running commands without an async done callback in a before and/or beforeEach, the next test is run before the command queue within the before/beforeEach is complete.

module.exports = {
    beforeEach: function (browser) { // or before
        browser.pause(1000, function() {
            console.log('beforeEach pause complete')
 })
@senocular
senocular / nw_api_wish.md
Last active August 31, 2017 08:36
Nightwatch API Wishlist
  • all callbacks use result object
  • custom commands, page object/section commands have same behavior/interface
  • client/api property consistency
  • better separation of user-defined apis and internal properties (page objects etc)
  • page/section objects have full api surface
  • Page objects, commands classes, having proper instanceof-checkable instances (no weird F() constructor)
  • Support command overrides rather than throwing an error
  • no legacy stuff
    • afterEach hook can receive the browser object only in its async form
  • async behavior consistency/clarity
@senocular
senocular / commandqueue.md
Last active December 1, 2016 17:13
NW Docs

[DEPRECATED - PLEASE USE THE NIGHTWATCH WIKI VERSION MOVING FORWARD]

https://github.com/nightwatchjs/nightwatch/wiki/Understanding-the-Command-Queue

Understanding the Command Queue

When Nightwatch runs a test, it processes its commands in a list known as the command queue. This list manages the asynchronous execution of the commands defined in that test.

As a queue, the command queue generally follows the rule of first in, first out (FIFO). The first command you call in a test is the first executed when the test runs. The second command is called next, followed by the next command up until the last command added, which becomes the last command executed.