Skip to content

Instantly share code, notes, and snippets.

View agoldis's full-sized avatar
🎯
Focused

Andrew Goldis agoldis

🎯
Focused
View GitHub Profile
@agoldis
agoldis / cypress.config.js
Created January 19, 2023 18:38
Record videos only for failed or flaky tests
const { defineConfig } = require("cypress");
const fs = require("fs");
module.exports = defineConfig({
video: true,
videoUploadOnPasses: true,
e2e: {
baseUrl: "https://en.wikipedia.org/",
specPattern: "cypress/integration/*.spec.js",
supportFile: "cypress/support/e2e.js",
@agoldis
agoldis / bitbucket-currents.yml
Created December 12, 2022 05:23
An example of running 3 parallel runners using Currents as a dashboard for cypress tests
image: cypress/base:14.16.0
## job definition for running E2E tests in parallel
e2e: &e2e
name: E2E tests
caches:
- node
- cypress
script:
- yarn install --frozen-lockfile
const failOnTimeout = (timeout = 10000) => {
return setTimeout(() => {
Cypress.runner.stop();
throw new Error("Timeout");
}, timeout);
};
describe("All tests", function () {
before(failOnTimeout);
// A generic "retry" mechanism
// Will retry invoking `fn` until it succeeds or will throw the latest exception
const withRetries =
<T extends (...args: any[]) => any, R = ReturnType<T>>(
fn: T,
retriesCount: number = 5
) =>
async (...args: Parameters<T>): Promise<R> => {
let i = retriesCount;
let error;
@agoldis
agoldis / .gitlab-ci.yaml
Created August 20, 2021 18:10
Running Cypress via Currents example
default:
image: cypress/base:14
stages:
- test
test:
image: cypress/browsers:node12.14.1-chrome85-ff81
stage: test
parallel: 50
@agoldis
agoldis / parse-git-url.ts
Last active July 31, 2021 08:11
Inline git-url-parse with Safari support, w/o normalize-url
// @ts-ignore
import isSsh from 'is-ssh';
// @ts-ignore
import parsePath from 'parse-path';
export function gitUrlParse(url: string) {
if (typeof url !== 'string') {
throw new Error('The url must be a string.');
}
@agoldis
agoldis / gist:be00343afe0fc5f9130c01f3cd914f5b
Created October 15, 2020 21:33
my 5 months daughter first lines of code
j,........D"      ≈xc≥≥≥≥≥
)
hguhv m hgfcr4frdfvfv); j,........D"≥≥≥≥≥
); j,........D"≥≥≥≥≥
); j,........D"≥≥≥≥≥
@agoldis
agoldis / mergeHTML.js
Last active September 18, 2020 07:47
Load modern and legacy scripts. Add multiple webpack targets into a single html file. html-webpack-plugin does not support merging multiple webpack targets. This naive and simple solution generates 2 html files and merges script tag into index.html.
#!/usr/bin/env node
const { readFileSync, writeFileSync } = require('fs');
const { parse } = require('node-html-parser');
const { resolve } = require('path');
const modernPath = resolve(__dirname, '..', 'dist', 'modern.html');
const legacyPath = resolve(__dirname, '..', 'dist', 'legacy.html');
const outputPath = resolve(__dirname, '..', 'dist', 'index.html');
@agoldis
agoldis / delete-github-package.graphql
Created October 25, 2019 05:26
Github - delete private package
# get version id
query($name: String!, $owner: String!) {
repository(name: $name, owner: $owner) {
id
name
registryPackages(first: 10) {
nodes {
versions(first: 10) {
nodes{
id
@agoldis
agoldis / setGithubRegistry.sh
Created October 16, 2019 17:47
Define credentials to private Github registry
#!/bin/sh
DIRECTORY=$(cd `dirname $0` && pwd)
cd $DIRECTORY/..
echo "Adding GitHub registry credentials to $DIRECTORY/../.npmrc"
echo "\n//npm.pkg.github.com/:_authToken=$GITHUB_SECRET" >> .npmrc