JS automation chat: https://t.me/js_for_testing
Contact me: https://xotabu4.github.io/
import { test } from '@playwright/test'; | |
/** | |
* Updates exsiting annotation or creates new one for current test | |
* | |
* @throws {Error} if called outside of test or before/after hooks | |
*/ | |
export function setAnnotation(annotation: { | |
type: string; | |
description: string; |
# nvm initialization | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
# setting auto-switch node version based on .nvmrc | |
# place this after nvm initialization! | |
autoload -U add-zsh-hook | |
load-nvmrc() { | |
local node_version="$(nvm version)" |
import { expect as baseExpect } from "@playwright/test"; | |
import type { APIResponse } from "@playwright/test"; | |
export const expect = baseExpect.extend({ | |
async responseToHaveErrorStatusCode( | |
requestFunction: () => Promise<APIResponse>, | |
expected: number | |
) { | |
const assertionName = "responseToHaveErrorStatusCode"; |
import { test } from '@playwright/test'; | |
/** | |
* Decorator that wraps a function with a Playwright test step. | |
* Used for reporting purposes. | |
* | |
* @example | |
``` | |
import { step } from './step_decorator'; | |
class MyTestClass { |
import type { | |
FullResult, Reporter, TestCase, TestResult, | |
} from '@playwright/test/types/testReporter'; | |
class PlaywrightSlackReporter implements Reporter { | |
allResults: Array<{ test: TestCase, result: TestResult }>; | |
constructor(private conf: { enabled: boolean, webhookUrl: string }) { | |
this.conf = conf; | |
this.allResults = []; |
JS automation chat: https://t.me/js_for_testing
Contact me: https://xotabu4.github.io/
// name: Trigger tests for run | |
// description: Triggers automated tests for a test run | |
// author: Oleksandr Khotemskyi <xotabu4@github.io> | |
// version: 1.0 | |
// includes: ^runs/view | |
// excludes: | |
// js: | |
$(document).ready( function () { | |
// TestRail project id -> gitlab pipeline |
// Example of function that will upload file for you. | |
// Works with Selenium Grid, and transfers file to selenium node automatically. | |
uploadFile(absFilePath) { | |
// Importing file detector from selenium-webdriver dependency, this is sub-dependency of protractor | |
var FileDetector = require('selenium-webdriver/remote/index.js').FileDetector; | |
// Setting file detector before upload. | |
browser.setFileDetector(new FileDetector()); | |
this.hiddenInputField.sendKeys(absFilePath).then(()=>{ |
/** Add custom browser and Element commands here */ | |
export {}; | |
declare global { | |
namespace WebdriverIO { | |
// interface Browser { | |
// browserCustomCommand: (arg: any) => Promise<void> | |
// } | |
// interface MultiRemoteBrowser { | |
// browserCustomCommand: (arg: any) => Promise<void> |
import { declareClickCommand } from './customCommands'; | |
export const baseConfig: WebdriverIO.Config = { | |
bail: 0, | |
automationProtocol: 'webdriver', | |
hostname: 'localhost', | |
protocol: 'http', | |
port: 4444, | |
path: '/wd/hub', | |
baseUrl: '', |