Skip to content

Instantly share code, notes, and snippets.

View InfoSec812's full-sized avatar

Deven Phillips InfoSec812

View GitHub Profile
@InfoSec812
InfoSec812 / index.html
Last active November 2, 2018 18:51
A simple HTML document to help understand the Document Object Model
<html>
<head>
<title>My DOM PAge</title>
<script language="JavaScript">
var clickCount = 0;
function buttonClickHandler() {
clickCount++;
document.querySelector("div.another_css_class").innerHTML = "Clicked " + clickCount + " times";
}
@InfoSec812
InfoSec812 / LogIn.vue
Created October 21, 2018 19:07
LogIn.vue implemented with API client and callbacks
<template>
<div class="window-width row justify-center items-start">
<q-card class="bg-white">
<q-card-media>
<img alt="Quasar logo" src="../assets/DHS-logo.jpg">
</q-card-media>
<!--q-card-separator/-->
<q-card-title></q-card-title>
@InfoSec812
InfoSec812 / Login.steps.js
Last active October 22, 2018 19:09
New scenario for our LogIn component
import Vue from 'vue';
import { defineFeature, loadFeature } from "jest-cucumber";
import Quasar from "quasar-framework";
import { mount, createLocalVue } from "@vue/test-utils";
import LogIn from "@/components/LogIn.vue";
import iconSet from "quasar-framework/icons/fontawesome";
import "quasar-extras/fontawesome";
Vue.config.silent = true;
@InfoSec812
InfoSec812 / Login.feature
Created October 20, 2018 03:34
Updated Login feature specifications
Feature: User login
Scenario: Entering credentials and clicking the login button
Given an instance of our Login component
And a mocked implementation of the login method
When I enter a username
And I enter a password
And I click the login button
Then I expect the login handler method to be executed
@InfoSec812
InfoSec812 / main.js
Created October 20, 2018 03:17
Add a REST library as a global property on the Vue object
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import "./registerServiceWorker";
import "./styles/quasar.styl";
import "quasar-framework/dist/quasar.ie.polyfills";
import iconSet from "quasar-framework/icons/fontawesome";
import "quasar-extras/fontawesome";
import Quasar from "quasar";
@InfoSec812
InfoSec812 / LogIn.vue
Created October 20, 2018 03:07
Implementation of login feature
<template>
<div class="column">>
<q-input v-model="username" />
<q-input v-model="password" type="password" />
<q-btn @click="login" label="Log In" />
</div>
</template>
<script>
export default {
name: 'Login',
@InfoSec812
InfoSec812 / Login.steps.js
Last active October 20, 2018 03:05
Feature specification wired to an automated test
import Vue from 'vue';
import { defineFeature, loadFeature } from "jest-cucumber";
import Quasar from "quasar-framework";
import { mount, createLocalVue } from "@vue/test-utils";
import LogIn from "@/components/LogIn.vue";
import iconSet from "quasar-framework/icons/fontawesome";
import "quasar-extras/fontawesome";
Vue.config.silent = true;
@InfoSec812
InfoSec812 / Login.feature
Last active October 20, 2018 03:06
Functional Specification For Vue Interaction Testing
Feature: User login
Scenario: Entering credentials and clicking the login button
Given an instance of our Login component
And a mocked implementation of the login method
When I enter a username
And I enter a password
And I click the login button
Then I expect the login handler method to be executed
@InfoSec812
InfoSec812 / gist:381e4576e97463bbfa308e5bba6f2c76
Last active October 6, 2018 03:30
Install Nightwatch And Nightwatch API
$ git clone git@github.com:InfoSec812/vuejs-bdd-primer.git
$ cd vuejs-bdd-primer
$ git checkout Implement-Code-To-Satisfy-Feature-Specification
$ git checkout -b Add-Nightwatch
$ npm install --save-dev nightwatch nightwatch-api
npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
npm WARN babel-loader@8.0.4 requires a peer of @babel/core@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
@InfoSec812
InfoSec812 / gist:1a6c137ced8a5ef602171728affc3c3d
Created October 6, 2018 02:59
Passing Feature Specification For Vue.js using jest-cucumber
$ npm test
> my-new-application@0.1.0 test /home/dphillips/Documents/RedHat/Workspace/vuejs-bdd-primer
> vue-cli-service test:unit
PASS tests/unit/steps/Home.steps.js
Home Page
✓ Opening the initial web page (187ms)
-------------|----------|----------|----------|----------|-------------------|