Skip to content

Instantly share code, notes, and snippets.

View oak-wildwood's full-sized avatar

Oak Cooper oak-wildwood

View GitHub Profile
@DesignByOnyx
DesignByOnyx / bootstrap-env-vars-test.ts
Last active January 16, 2024 02:15
Helper for testing different environment variables for individual tests
const bootstrapEnvVarsTests = <ModuleType>(modulePath: string) => {
const OLD_ENV = process.env;
beforeEach(() => {
// this allows us to reassign env vars for individual tests
jest.resetModules();
process.env = { ...OLD_ENV };
});
afterAll(() => {
process.env = OLD_ENV;
#!/bin/bash
branchname=${1:-$(git rev-parse --abbrev-ref HEAD)}
if ! [ -x "$(command -v jq)" ]; then
echo 'Error: "jq" is not installed.' >&2
exit 1
fi
if [ ! $SECRET_GH_TOKEN ]; then
@ArturT
ArturT / Cypress-GitHub-Actions-JavaScript.md
Last active October 4, 2019 16:01
Cypress parallel testing on GitHub Actions. How to use GitHub matrix to run parallel jobs to split Cypress.io tests with https://knapsackpro.com/?utm_source=github&utm_medium=gist&utm_campaign=cypress-on-github-actions&utm_content=sign_up

@knapsack-pro/cypress supports environment variables provided by GitHub Actions to run your tests. You have to define a few things in .github/workflows/main.yaml config file.

  • You need to set KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS environment variable in GitHub repository Settings -> Secrets. See creating and using secrets in GitHub Actions.
  • You should create as many parallel jobs as you need with matrix.ci_node_total and matrix.ci_node_index properties. If your test suite is slow you should use more parallel jobs.

Below you can find config for GitHub Actions.

Video demo Cypress and GitHub Actions

https://youtu.be/06Ghp1-coVo