Skip to content

Instantly share code, notes, and snippets.

View krishna-acondy's full-sized avatar

Krishna Acondy krishna-acondy

View GitHub Profile
{
"WebDriver": {
"Type": "remote",
"Chrome": {
"Headless": "true"
},
"Remote": {
"HubUrl": "http://localhost:4444/wd/hub"
}
},
@krishna-acondy
krishna-acondy / Jenkinsfile
Last active June 26, 2019 11:03
Jenkins CI Script
def dockerArtifactoryRegistry = "your-docker-registry-here"
def timestamp = new Date().format("MMddHHmmss", TimeZone.getTimeZone('UTC'))
pipeline {
agent {
node {
label 'docker'
customWorkspace "automated-ui-tests"
}
}
namespace AutomatedUiTests.Pages
{
public abstract class BasePage
{
public string Url => WebDriver.Url;
public void Close()
{
WebDriver.Close();
}
using System;
namespace AutomatedUiTests.Components
{
public interface IComponent
{
void WaitFor(TimeSpan timeSpan);
void WaitUntil(Func<bool> condition, int timeoutValue);
void Hover();
}
@krishna-acondy
krishna-acondy / TestContext.cs
Created June 26, 2019 09:34
Automated UI Test Context
using System.IO;
using Gauge.CSharp.Lib.Attribute;
using Microsoft.Extensions.Configuration;
using OpenQA.Selenium;
namespace AutomatedUiTests
{
public class TestContext
{
public static IConfiguration Configuration { get; private set; }
version: '3.7'
services:
web-app:
container_name: web-app-${DOCKER_SUFFIX}
image: <Path to your app's docker image>
networks:
- automated-ui-tests
# Include any other components of your application here
@krishna-acondy
krishna-acondy / todos.component.spec.ts
Last active May 23, 2019 22:00
Angular Unit Testing - TodosComponent Simplest
describe('TodosComponent', () => {
let testHarness: TestHarness<TodosComponent>;
beforeEach(async () => {
await setupTestModule(TodosTestModule);
testHarness = createTestHarness(TodosComponent);
});
it('should create', () => {
expect(testHarness.hasComponentCreated).toBeTruthy();
@krishna-acondy
krishna-acondy / test-harness.ts
Created May 23, 2019 21:55
Angular Unit Testing - Test Harness
export class TestHarness<T> {
constructor(public component: T, public fixture: ComponentFixture<Component>) { }
get hasComponentCreated() {
return !!this.component;
}
detectChanges() {
this.fixture.detectChanges();
}
@krishna-acondy
krishna-acondy / create-test-module.ts
Created May 23, 2019 21:47
Angular Unit Testing - Creating Test Modules
export function setupTestModule<T>(moduleType: Type<T>, providers: any[] = []) {
return TestBed.configureTestingModule({
imports: [
moduleType
],
providers: providers
})
.compileComponents();
}
@krishna-acondy
krishna-acondy / dashboard.test.module.ts
Last active May 23, 2019 21:35
Angular Unit Testing - DashboardTestModule
@NgModule({
declarations: [
DashboardComponent
],
imports: [
CommonModule,
TodosTestModule
],
providers: [
{ provide: DashboardService, useClass: DashboardServiceMock }