Skip to content

Instantly share code, notes, and snippets.

@patricksevat
patricksevat / getSpecFiles.js
Created November 25, 2019 19:16
Regex / grep generator
// getSpecFiles.js
const glob = require('glob');
const { readFileSync } = require('fs-extra');
function getFilteredSpecFiles(specs, opts = {}) {
const { glob, grep } = getRegularExpression(opts);
const fileNames = getGlobMatches(specs);
const includedSpecFiles = [];
@patricksevat
patricksevat / wdio.conf.js
Created November 25, 2019 19:12
Advanced wdio conf
// ./wdio.conf.js
const argv = require('yargs').argv;
const { getFilteredSpecFiles, getRegularExpression } = require('./getSpecFiles');
const cmdOpts = {
'happy-flow': argv.happyFlow,
target: argv.target,
};
@patricksevat
patricksevat / grep-example.spec.ts
Created November 25, 2019 19:05
Spec with #happy-flow
// ./spec/grep-example.spec.ts
describe('various tests', () => {
it('I will be executed #happy-flow', () => {});
it('I will be filtered', () => {});
});
@patricksevat
patricksevat / wdio.conf.js
Created November 25, 2019 19:04
Wdio configuration with jasmine #happy-flow grep
// wdio.conf.js
exports.config = {
specs: ['spec/**/*.spec.ts'],
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 60000,
grep: '#happy-flow',
invertGrep: false,
},
// ... other config
@patricksevat
patricksevat / bank-account.ts
Created November 20, 2019 20:32
Naive, not DRY implementation of an Component Object
// ./objects/features/bank-account.ts
export class BankAccountObject {
// internal id
componentName = 'bank-account';
// this is the root element: <my-bank-account />
element = 'my-bank-account';
// this is a (deep) element that renders latest
elementToRender = '#async-fetch-bank-account-balance';
@patricksevat
patricksevat / getSpecFiles.js
Created November 20, 2019 20:27
Regex / grep generator
// getSpecFiles.js
const glob = require('glob');
const { readFileSync } = require('fs-extra');
function getFilteredSpecFiles(specs, opts = {}) {
const { glob, grep } = getRegularExpression(opts);
const fileNames = getGlobMatches(specs);
const includedSpecFiles = [];
@patricksevat
patricksevat / wdio.conf.js
Created November 20, 2019 20:26
Advanced wdio conf
// ./wdio.conf.js
const argv = require('yargs').argv;
const { getFilteredSpecFiles, getRegularExpression } = require('./getSpecFiles');
const cmdOpts = {
smoke: argv.smoke,
target: argv.target,
};
@patricksevat
patricksevat / grep-example.spec.ts
Created November 20, 2019 20:23
spec example with hashtag
// ./spec/grep-example.spec.ts
describe('various tests', () => {
it('I will be executed #smoke', () => {});
it('I will be filtered', () => {});
});
@patricksevat
patricksevat / wdio.conf.js
Created November 20, 2019 20:22
wdio conf with jasmine grep
// wdio.conf.js
exports.config = {
specs: ['spec/**/*.spec.ts'],
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 60000,
grep: '#smoke',
invertGrep: false,
},
// ... other config
@patricksevat
patricksevat / bank-account.ts
Created November 20, 2019 20:10
Refactored Component Object
// ./objects/features/bank-account.ts
import { ComponentObjectBase } from '../base';
export class BankAccountObject extends ComponentObjectBase {
componentName = 'bank-account';
element = 'my-bank-account';
elementToRender = '[data-test="async-fetch-bank-account-balance"]';
}