Skip to content

Instantly share code, notes, and snippets.

View nottyo's full-sized avatar

Traitanit Huangsri nottyo

View GitHub Profile
@nottyo
nottyo / cypress.json
Last active July 14, 2019 14:05
cypress.nyan.json
{
"reporter": "nyan"
}
@nottyo
nottyo / cypress.json
Last active December 20, 2019 17:18
cypress.mochawesome.json
{
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/report/mochawesome-report",
"overwrite": false,
"html": false,
"json": true,
"timestamp": "mmddyyyy_HHMMss"
}
}
@nottyo
nottyo / report-config.json
Created July 14, 2019 14:18
mochawesome.json
{
"reportDir": "cypress/report/mochawesome-report",
"overwrite": true,
"html": true,
"json": true
}
}
@nottyo
nottyo / cypress_runner.js
Created July 16, 2019 08:02
cypress custom test runner
const cypress = require('cypress')
const yargs = require('yargs')
const { merge } = require('mochawesome-merge')
const marge = require('mochawesome-report-generator')
const rm = require('rimraf')
const cypressConfig = require('./cypress')
const ls = require('ls')
const argv = yargs.options({
'browser': {
alias: 'b',
@nottyo
nottyo / index.js
Last active July 16, 2019 10:11
cypress support file (cypress/support/index.js)
const addContext = require('mochawesome/addContext')
Cypress.on('test:after:run', (test, runnable) => {
if (test.state === 'failed') {
const screenshotFileName = `${runnable.parent.title} -- ${test.title} (failed).png`
addContext({ test }, `assets/${Cypress.spec.name}/${screenshotFileName}`)
}
})
@nottyo
nottyo / cypress.json
Created July 16, 2019 10:13
cypress.screenshot.json
{
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/report/mochawesome-report",
"overwrite": false,
"html": false,
"json": true,
"timestamp": "mmddyyyy_HHMMss"
},
"screenshotsFolder": "cypress/report/mochawesome-report/assets"
@nottyo
nottyo / main.js
Created August 3, 2019 10:30
navigate to phone call
function clickme() {
window.location.href = "tel://0234567890";
}
@nottyo
nottyo / main.js
Last active August 3, 2019 10:37
wrap phone call navigation
function setLocationHref(url) {
window.location.href = url
}
// visible for testing
window.setLocationHref = setLocationHref
function clickme() {
setLocationHref("tel://0234567890")
}
@nottyo
nottyo / url_scheme.spec.js
Created August 3, 2019 10:41
๊URL Scheme Test
describe('URL Scheme Test', () => {
beforeEach(() => {
cy.visit(`./url_scheme.html`)
})
it('should click to navigate', () => {
const winSetLocationHrefStub = (url) => {
expect(url).to.eq('tel://0234567890')
}
cy.window().then(window => {
cy.stub(window, 'setLocationHref', winSetLocationHrefStub)
@nottyo
nottyo / main_prompt.js
Created August 3, 2019 11:02
window.prompt()
function clickme() {
var name = window.prompt("Please enter your name.")
if (name) {
document.getElementById("result").innerHTML = "Hello " + name + " !"
} else {
document.getElementById("result").innerHTML = "You did not input anything"
}
}