Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
Simplify skipping test setup
Rūdolfs Ošiņš committed 2 months ago
commit 9af7ee637f30ea7aeff614dd15a9d5d7842135d0
parent d975609
2 files changed +44 -8
modified CONTRIBUTING.md
@@ -13,6 +13,34 @@ simple guidelines.
* Follow the guidelines when proposing code changes (see below).
* Write properly formatted git commits (see below).

+
Running Tests
+
-------------
+

+
The test suite includes end-to-end (e2e) tests that run against the built
+
application.
+

+
**Basic usage:**
+

+
    npm run test:e2e
+

+
**Skipping setup:**
+

+
The test suite performs setup operations before running tests:
+
* Building the application bundle
+
* Creating test fixtures (repositories with test data)
+

+
On subsequent test runs, you can skip this setup to save time:
+

+
    SKIP_SETUP=true npm run test:e2e
+

+
Use this when:
+
* You haven't changed any source code since the last test run
+
* The test fixtures are already created
+
* You want to iterate quickly on test development
+

+
**Note:** If you've made code changes or are getting unexpected test failures,
+
remove the `SKIP_SETUP` flag to ensure tests run against the latest build.
+

Proposing changes
-----------------
When proposing changes via a patch:
modified tests/support/globalSetup.ts
@@ -54,11 +54,20 @@ export default async function globalSetup(): Promise<() => void> {
    process.exit(1);
  }

-
  console.log("⚡ Starting parallel setup...");
+
  // Evaluated once at startup; captured by async setup operations.
+
  // Set SKIP_SETUP=true to skip both build and fixture creation on subsequent runs.
+
  // See CONTRIBUTING.md for details.
+
  const shouldSetup = !process.env.SKIP_SETUP;
+

+
  if (shouldSetup) {
+
    console.log("⚡ Starting parallel setup...");
+
  } else {
+
    console.log("⏭️  Skipping setup (SKIP_SETUP is set)");
+
  }

  // Run build and fixture setup in parallel
  const buildPromise = (async () => {
-
    if (!process.env.SKIP_BUILD) {
+
    if (shouldSetup) {
      console.log("  🔨  Starting build...");
      const { execa: exec } = await import("execa");
      try {
@@ -74,13 +83,11 @@ export default async function globalSetup(): Promise<() => void> {
        }
        throw error;
      }
-
    } else {
-
      console.log("  🔨  Skipping build");
    }
  })();

  const fixturesPromise = (async () => {
-
    if (!process.env.SKIP_FIXTURE_CREATION) {
+
    if (shouldSetup) {
      console.log("  🗂️  Starting fixture creation...");
      await removeWorkspace();
    }
@@ -101,7 +108,7 @@ export default async function globalSetup(): Promise<() => void> {
      gitOptions: gitOptions["alice"],
    });

-
    if (!process.env.SKIP_FIXTURE_CREATION) {
+
    if (shouldSetup) {
      await palm.startNode({
        web: {
          pinned: {
@@ -142,7 +149,6 @@ export default async function globalSetup(): Promise<() => void> {
      }
      await palm.stopNode();
    } else {
-
      console.log("  🗂️  Skipping fixture creation");
      await palm.startHttpd(config.nodes.defaultHttpdPort);
    }

@@ -152,7 +158,9 @@ export default async function globalSetup(): Promise<() => void> {
  // Wait for both build and fixtures to complete
  const [, peerManager] = await Promise.all([buildPromise, fixturesPromise]);

-
  console.log("🚀 Setup complete, ready to run tests");
+
  if (shouldSetup) {
+
    console.log("🚀 Setup complete, ready to run tests");
+
  }

  return async () => {
    await peerManager.shutdown();