mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-18 19:30:27 +08:00
Simplify skipping test setup
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user