Skip to navigation

Step routing, written as tests

Each example on this page varies one setting in a short procedure, shown as prose, detected tests, inline tests, and a standalone spec. For what each tab holds, see Navigation and interaction.

Detection finds no steps in these procedures, because the URLs and commands sit in code. So every variant runs the same step statements, and the detected and inline files differ only in detectSteps.

An onFail or onWarning entry on a step that passes never applies. Those examples show the shape, and their effect says what happens when the entry applies.

Step routing permutations

onPass, continue

Varies: step.onPass · Value: [{"continue": true}] · Effect: moves on to the next step. This is the default after a pass.

prose.md
# Print tool versions
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

onPass, stop

Varies: step.onPass · Value: [{"stop": "test"}] · Effect: stops the test after this step passes. The npm step is skipped, and the test passes.

prose.md
# Print the Node.js version only
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

onPass, goToStep

Varies: step.onPass · Value: [{"goToStep": "path"}] · Effect: jumps to the step whose stepId is path. The npm step doesn’t run and isn’t in the results.

prose.md
# Skip ahead after a version check
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```
3. Find the Node.js executable:
```shell
command -v node
```

onPass, retry

Varies: step.onPass · Value: [{"retry": {"limit": 1}}] · Effect: runs the passing step once more, then falls through to the default and continues. The result reports "attempts": 2.

prose.md
# Print the Node.js version twice
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

onFail, continue

Varies: step.onFail · Value: [{"continue": true}] · Effect: applies only if the step fails: the next step still runs, but the test fails. Here the step passes.

prose.md
# Print tool versions even if one fails
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

onFail, stop

Varies: step.onFail · Value: [{"stop": "test"}] · Effect: applies only if the step fails, and stops the test’s remaining steps. That’s also the default. Here the step passes.

prose.md
# Stop when Node.js is missing
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

onFail, goToStep

Varies: step.onFail · Value: [{"goToStep": "path"}] · Effect: applies only if the step fails, and jumps to path. The failure still fails the test. Here the step passes.

prose.md
# Find Node.js if the version check fails
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```
3. Find the Node.js executable:
```shell
command -v node
```

onFail, retry with limit

Varies: step.onFail · Value: [{"retry": {"limit": 2}}] · Effect: the check fails once, and the first retry passes, so the step and the test pass with "attempts": 2. Retries run with no delay.

prose.md
# Wait for a service to be ready
1. Check that the service is ready. If the check fails, check again:
```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'dd-data-route-onfail-retry-limit');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

onFail, retry with delay

Varies: step.onFail · Value: [{"retry": {"limit": 2, "delay": 500}}] · Effect: waits 500 milliseconds before each retry.

prose.md
# Wait for a service to be ready
1. Check that the service is ready. If the check fails, check again:
```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'dd-data-route-onfail-retry-delay');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

onFail, retry with backoff: fixed

Varies: step.onFail · Value: [{"retry": {"limit": 3, "delay": 500, "backoff": "fixed"}}] · Effect: waits the same 500 milliseconds before every retry. This is the default backoff.

prose.md
# Wait for a service to be ready
1. Check that the service is ready. If the check fails, check again:
```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'dd-data-route-onfail-retry-backoff-fixed');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

onFail, retry with backoff: exponential

Varies: step.onFail · Value: [{"retry": {"limit": 3, "delay": 500, "backoff": "exponential"}}] · Effect: doubles the wait before each retry: 500, then 1000, then 2000 milliseconds.

prose.md
# Wait for a service to be ready
1. Check that the service is ready. If the check fails, check again:
```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'dd-data-route-onfail-retry-backoff-exponential');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```

onFail, retry then continue

Varies: step.onFail · Value: [{"retry": {"limit": 2}}, {"continue": true}] · Effect: retries first. If the step still fails after its retries, the next entry applies and the test moves on. Here the first retry passes.

prose.md
# Wait for a service, then move on
1. Check that the service is ready. If the check fails, check again:
```shell
node -e "const fs=require('fs'),f=require('path').join(require('os').tmpdir(),'dd-data-route-onfail-retry-then-continue');if(fs.existsSync(f)){fs.rmSync(f)}else{fs.writeFileSync(f,'');console.error('Not ready yet.');process.exit(1)}"
```
2. Print the npm version:
```shell
npm --version
```

onSkip, continue

Varies: step.onSkip · Value: [{"continue": true}] · Effect: the help step’s if is false, so it’s skipped, and the test moves on. This is the default after a skip.

prose.md
# Show help only when Node.js fails
1. Print the Node.js version:
```shell
node --version
```
2. If that failed, print the help for `node`:
```shell
node --help
```
3. Print the npm version:
```shell
npm --version
```

onSkip, stop

Varies: step.onSkip · Value: [{"stop": "test"}] · Effect: the help step is skipped, so the test stops. The npm step is skipped too, and the test passes.

prose.md
# Stop when the help step is skipped
1. Print the Node.js version:
```shell
node --version
```
2. If that failed, print the help for `node`:
```shell
node --help
```
3. Print the npm version:
```shell
npm --version
```

onSkip, goToStep

Varies: step.onSkip · Value: [{"goToStep": "path"}] · Effect: the help step is skipped and jumps to path, so the npm step doesn’t run.

prose.md
# Jump past the help steps
1. Print the Node.js version:
```shell
node --version
```
2. If that failed, print the help for `node`:
```shell
node --help
```
3. Print the npm version:
```shell
npm --version
```
4. Find the Node.js executable:
```shell
command -v node
```

onSkip, retry

Varies: step.onSkip · Value: [{"retry": {"limit": 1}}] · Effect: a step skipped by its if never ran, so retry doesn’t run it again. It re-runs only a step whose own action returned SKIPPED.

prose.md
# Retry a skipped step
1. Print the Node.js version:
```shell
node --version
```
2. If that failed, print the help for `node`:
```shell
node --help
```
3. Print the npm version:
```shell
npm --version
```

onWarning, continue

Varies: step.onWarning · Value: [{"continue": true}] · Effect: applies only if the step ends with a warning, and moves on. That’s also the default. Here the step passes.

prose.md
# Print tool versions after a warning
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

onWarning, stop

Varies: step.onWarning · Value: [{"stop": "test"}] · Effect: applies only if the step ends with a warning, and stops the test. Here the step passes.

prose.md
# Stop after a warning
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

onWarning, goToStep

Varies: step.onWarning · Value: [{"goToStep": "path"}] · Effect: applies only if the step ends with a warning, and jumps to path. Here the step passes.

prose.md
# Jump ahead after a warning
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```
3. Find the Node.js executable:
```shell
command -v node
```

onWarning, retry

Varies: step.onWarning · Value: [{"retry": {"limit": 1}}] · Effect: applies only if the step ends with a warning, and runs it again. Here the step passes.

prose.md
# Retry after a warning
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```

Entry if, string

Varies: step.onPass[].if · Value: "$$platform oneOf [linux, mac, windows]" · Effect: the entry applies only when its condition is true. It’s true here, so the step jumps to path.

prose.md
# Skip ahead on desktop platforms
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```
3. Find the Node.js executable:
```shell
command -v node
```

Entry if, array

Varies: step.onPass[].if · Value: ["$$outputs.exitCode == 0", "$$outputs.stdio.stdout matches /^v/"] · Effect: every condition must be true. An entry’s condition reads the step’s own $$outputs.

prose.md
# Skip ahead after a valid version
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```
3. Find the Node.js executable:
```shell
command -v node
```

Entry if, false

Varies: step.onPass[].if · Value: "$$outputs.exitCode != 0" · Effect: the condition is false, so the entry doesn’t apply and the default runs: the test continues to the npm step.

prose.md
# Fall back to the default route
1. Print the Node.js version:
```shell
node --version
```
2. Print the npm version:
```shell
npm --version
```