Skip to content

Instantly share code, notes, and snippets.

View Mkots's full-sized avatar
😃

Vitaliy Komarov Mkots

😃
  • Kyiv
  • 16:55 (UTC +03:00)
View GitHub Profile
@Mkots
Mkots / Dockerfile
Created May 9, 2026 13:05
Playwright DevContainer
FROM mcr.microsoft.com/playwright:v1.56.1-noble
RUN apt-get update && apt-get install -y \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libasound2t64 && rm -rf /var/lib/apt/lists/*
@Mkots
Mkots / ChatTestHelper.ts
Created July 21, 2025 16:38
XState + Playwright + TS
import { Page } from '@playwright/test';
import { interpret } from 'xstate';
import { chatMachine } from './chatMachine'
export class ChatTestHelper {
private service: any;
private page: Page;
@Mkots
Mkots / Instruction.md
Created July 14, 2025 11:19
AI Madness

Init

  1. npm init -y
  2. npm init playwright@latest

Create Snapshot

  1. Create a test file GetSnapshot.test.ts
import { test, expect } from '@playwright/test';  
  
@Mkots
Mkots / gotoWithRetry.ts
Created April 10, 2025 11:00
Playwright: goro with retries
async function gotoWithRetry(page: Page, url: string, options = {}) {
const maxRetries = 3;
const defaultOptions = { timeout: 20000, waitUntil: 'load' as ('load') };
const mergedOptions = { ...defaultOptions, ...options };
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
await page.goto(url, mergedOptions);
return;
} catch (error) {
@Mkots
Mkots / state_server.js
Created March 4, 2025 19:34
Zustand state server
import express from 'express';
import { create } from 'zustand';
const useStore = create((set, get) => ({
state: {},
setState: (key, value, ttl) => {
const expiresAt = ttl ? Date.now() + ttl * 1000 : null;
set((state) => ({
state: { ...state.state, [key]: { value, expiresAt } }
}));
@Mkots
Mkots / .tsconfig.json
Created April 5, 2024 18:19
AVA + TS + Node 18.20
{
"compilerOptions": {
"module": "ESNext",
"target": "es5",
"moduleResolution": "Node"
}
}
@Mkots
Mkots / Base.ts
Last active January 22, 2024 18:29
Locator overriding
export class Base {
readonly helloBtn: Locator;
constructor(page: Page) {
this.page = page
this.helloBtn = this.page.locator("hello")
}
public sendHello = async () => {
@Mkots
Mkots / Timer.tsx
Created March 27, 2020 08:26
Timer
import React, { Component } from "react";
import ReactDOM from "react-dom";
interface IProps {
from: number;
}
interface IState {
current: number;
isPause: boolean;
const getSnail = (size = 5) => {
const snail = Array.from({ length: size }, () =>
Array.from({ length: size })
);
for (round = 0, value = 0; round < size / 2; ++round) {
for (j = round; j < size - 1 - round; ++j) {
snail[round][j] = ++value;
}
for (i = round; i < size - 1 - round; ++i) {
snail[i][size - 1 - round] = ++value;
@Mkots
Mkots / plugins index.js
Last active February 13, 2020 12:50
Cypress Yandex Browser
const webpack = require('@cypress/webpack-preprocessor');
const execa = require('execa');
const findBrowser = () => {
const browserPath = '/usr/bin/yandex-browser';
return execa(browserPath, ['--version']).then(result => {
const [, version] = /Yandex (\d+\.\d+\.\d+\.\d+)/.exec(result.stdout);
const majorVersion = parseInt(version.split('.')[0]);
return {