feat: --clear-data flag + typed attribute selectors (#48)

* feat(test): add --clear-data flag to clear app data on launch

* test+docs: cover --clear-data flag in CLI parser test and reference

* feat(spec): type AttrSelector with known attribute names

Replace AttrSelector = Record<string, string> with KnownAttrSelectors
plus a string|boolean index signature, so authors get autocomplete and
type-checking on testTag / focused / clickable / etc. while raw driver
attributes still type-check via the fallback. Boolean state attributes
accept native booleans; goja stringifies them at the marshal boundary.

AccessibilityElement.attrs becomes RawAttrs (typed string-valued shape
of the same canonical names) so element.attrs.testTag autocompletes.

* test(verifier): native boolean selector value matches focused=true

* docs+folio: use native boolean for focused selector and document typed attrs
This commit is contained in:
pj authored and GitHub committed 2026-04-27 01:02:21 +07:00
1 parent c76745e5f1
commit dd54c24c4e
10 files changed
+112 -5

No files matched your search

+2
View File
@@ -23,6 +23,7 @@ type testOptions struct {
duration time.Duration
seed int64
output string
clearData bool
}
const topUsage = `sanderling is a property-based UI fuzzer for mobile apps.
@@ -51,6 +52,7 @@ func parseTestArgs(args []string, stderr io.Writer) (testOptions, error) {
flagSet.DurationVar(&options.duration, "duration", 5*time.Minute, "total test duration")
flagSet.Int64Var(&options.seed, "seed", 0, "RNG seed (0 = random)")
flagSet.StringVar(&options.output, "output", "./runs", "output directory for traces")
flagSet.BoolVar(&options.clearData, "clear-data", false, "clear app data before launching so the run starts from a fresh install")
if err := flagSet.Parse(args); err != nil {
return testOptions{}, err
}
+17
View File
@@ -32,6 +32,23 @@ func TestParseTestArgs_Defaults(t *testing.T) {
if options.seed != 0 {
t.Errorf("seed default: got %d, want 0", options.seed)
}
if options.clearData {
t.Errorf("clearData default: got true, want false")
}
}
func TestParseTestArgs_ClearDataFlag(t *testing.T) {
options, err := parseTestArgs([]string{
"--spec", "s.ts",
"--bundle-id", "com.example",
"--clear-data",
}, io.Discard)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !options.clearData {
t.Errorf("expected clearData=true, got false")
}
}
func TestParseTestArgs_AllFlags(t *testing.T) {
+1
View File
@@ -17,5 +17,6 @@ func runTestPipeline(ctx context.Context, options testOptions, stdout io.Writer)
Duration: options.duration,
Seed: options.seed,
Output: options.output,
ClearData: options.clearData,
}, stdout)
}