nativeproof 0.10.3 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ All notable changes to NativeProof are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/) and the project adheres to
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## 0.10.4
8
+
9
+ Per-project spec sets and WebdriverIO tuning pass-through, for suites that run a different set of
10
+ specs per platform and need longer timeouts on slow devices.
11
+
12
+ **Added**
13
+
14
+ - `DeviceProject.specs` — per-project spec globs that override the top-level `testDir`/`testMatch`,
15
+ for suites where platforms run different specs (e.g. a shared set plus a platform-specific set:
16
+ `["e2e/shared/**\/*.spec.ts", "e2e/android/**\/*.spec.ts"]`). A `--spec` CLI override still wins.
17
+ Precedence: `--spec` (comma-separated) > `project.specs` > `testDir`/`testMatch`.
18
+ - WebdriverIO tuning pass-throughs on `RunnerConfig`: `connectionRetryTimeout`,
19
+ `connectionRetryCount`, `waitforTimeout`, `bail`, and `logLevel`. Each is forwarded to the
20
+ synthesised WebdriverIO config only when set, so WebdriverIO's own defaults apply otherwise —
21
+ slow software-GPU emulators in particular often need longer connection/wait timeouts. `bail: 0`
22
+ is meaningful (never bail) and is still forwarded.
23
+
7
24
  ## 0.10.3
8
25
 
9
26
  Out-of-the-box setup: scaffolding, minimal config, a route-optional mock contract, and typed
package/README.md CHANGED
@@ -100,7 +100,13 @@ npx appium driver doctor uiautomator2
100
100
 
101
101
  ## Quick start
102
102
 
103
- Four steps from zero to a green run on Android.
103
+ Scaffold the starting files with one command, then fill in your app's seam:
104
+
105
+ ```bash
106
+ npx nativeproof init # writes nativeproof.config.ts + a sample spec (never overwrites)
107
+ ```
108
+
109
+ Then four steps from zero to a green run on Android — or set it all up by hand:
104
110
 
105
111
  **1. Configure** — one `nativeproof.config.ts` at the project root:
106
112
 
package/dist/config.d.ts CHANGED
@@ -36,6 +36,13 @@ export interface DeviceProject {
36
36
  * for a smoke run against whatever is already installed. Anything you set here wins.
37
37
  */
38
38
  capabilities?: Record<string, unknown>;
39
+ /**
40
+ * Spec globs for THIS project, relative to the project root — overriding the top-level
41
+ * `testDir`/`testMatch` when set. For suites where platforms run different specs (e.g. a shared
42
+ * set plus a platform-specific set: `["e2e/shared/**\/*.spec.ts", "e2e/android/**\/*.spec.ts"]`).
43
+ * A `--spec` CLI override still wins over this.
44
+ */
45
+ specs?: string[];
39
46
  }
40
47
  /**
41
48
  * The standard capabilities for a platform, so a consumer doesn't restate the same
@@ -47,12 +54,27 @@ export declare function defaultCapabilities(platform: "android" | "ios"): Record
47
54
  export interface RunnerConfig {
48
55
  /** Directory holding the specs (default "tests"). */
49
56
  testDir?: string;
50
- /** Glob within `testDir` (default "**\/*.spec.ts"). */
57
+ /** Glob within `testDir` (default "**\/*.spec.ts"). A project's own `specs` overrides this. */
51
58
  testMatch?: string;
52
59
  projects: DeviceProject[];
53
60
  appium?: AppiumOptions;
54
61
  /** Per-test timeout in ms (default 240000). */
55
62
  mochaTimeout?: number;
63
+ /**
64
+ * WebdriverIO pass-throughs for tuning real-device runs. Each is forwarded only when set, so
65
+ * WebdriverIO's own defaults apply otherwise. Slow software-GPU emulators in particular often
66
+ * need a longer `connectionRetryTimeout` / `waitforTimeout` than the defaults.
67
+ */
68
+ /** Per-command/session connection timeout in ms (wdio default 120000). */
69
+ connectionRetryTimeout?: number;
70
+ /** Connection retry count (wdio default 3). */
71
+ connectionRetryCount?: number;
72
+ /** Default auto-wait timeout in ms for `waitUntil`/`waitFor*` (wdio default 5000). */
73
+ waitforTimeout?: number;
74
+ /** Stop the run after N failures; 0 = never bail (wdio default 0). */
75
+ bail?: number;
76
+ /** WebdriverIO log level (wdio default "info"). */
77
+ logLevel?: "trace" | "debug" | "info" | "warn" | "error" | "silent";
56
78
  }
57
79
  export interface NativeProofConfig<Ctx = unknown> extends RunnerConfig {
58
80
  /** The app under test (from `defineApp`). */
@@ -72,9 +94,7 @@ export interface RunnerEnv {
72
94
  /** Pick the project by explicit name, else by platform, else the first one. */
73
95
  export declare function resolveProject(config: RunnerConfig, env?: RunnerEnv): DeviceProject;
74
96
  /**
75
- * Translate an NativeProof config into a WebdriverIO `config` object. Spec paths are made
76
- * absolute against `cwd` (the project root) because the synthesised config is loaded from
77
- * inside `node_modules`, so a relative glob would resolve against the wrong directory.
97
+ * Translate an NativeProof config into a WebdriverIO `config` object.
78
98
  */
79
99
  export declare function buildWdioConfig(config: RunnerConfig, env?: RunnerEnv, cwd?: string): Record<string, unknown>;
80
100
  /** Find an `nativeproof.config.*` in `dir`, or null. `exists` is injectable for testing. */
package/dist/config.js CHANGED
@@ -34,21 +34,32 @@ export function resolveProject(config, env = {}) {
34
34
  return first;
35
35
  }
36
36
  /**
37
- * Translate an NativeProof config into a WebdriverIO `config` object. Spec paths are made
38
- * absolute against `cwd` (the project root) because the synthesised config is loaded from
39
- * inside `node_modules`, so a relative glob would resolve against the wrong directory.
37
+ * Resolve the spec globs (absolute) for a run, in precedence order: an explicit `--spec` override
38
+ * (comma-separated allowed), else the active project's own `specs`, else the top-level
39
+ * `testDir`/`testMatch`. Absolute against `cwd` because the synthesised config is loaded from inside
40
+ * `node_modules`, so a relative glob would resolve against the wrong directory.
40
41
  */
41
- export function buildWdioConfig(config, env = {}, cwd = process.cwd()) {
42
- const project = resolveProject(config, env);
42
+ function resolveSpecs(config, project, env, cwd) {
43
+ const abs = (glob) => path.resolve(cwd, glob);
44
+ if (env.spec)
45
+ return env.spec.split(",").map((glob) => abs(glob.trim()));
46
+ if (project.specs && project.specs.length > 0)
47
+ return project.specs.map(abs);
43
48
  const testDir = config.testDir ?? "tests";
44
49
  const testMatch = config.testMatch ?? "**/*.spec.ts";
45
- const specs = [path.resolve(cwd, env.spec ?? `${testDir}/${testMatch}`)];
46
- return {
50
+ return [abs(`${testDir}/${testMatch}`)];
51
+ }
52
+ /**
53
+ * Translate an NativeProof config into a WebdriverIO `config` object.
54
+ */
55
+ export function buildWdioConfig(config, env = {}, cwd = process.cwd()) {
56
+ const project = resolveProject(config, env);
57
+ const wdio = {
47
58
  runner: "local",
48
59
  hostname: env.appiumHost ?? config.appium?.host ?? "127.0.0.1",
49
60
  port: env.appiumPort ?? config.appium?.port ?? 4723,
50
61
  path: env.appiumPath ?? config.appium?.path ?? "/wd/hub",
51
- specs,
62
+ specs: resolveSpecs(config, project, env, cwd),
52
63
  maxInstances: 1,
53
64
  capabilities: [{ ...defaultCapabilities(project.platform), ...project.capabilities }],
54
65
  framework: "mocha",
@@ -64,6 +75,19 @@ export function buildWdioConfig(config, env = {}, cwd = process.cwd()) {
64
75
  await captureState(failureEvidenceName(test)).catch(() => { });
65
76
  },
66
77
  };
78
+ // Optional WebdriverIO tuning — forwarded only when the consumer set it, so wdio's defaults apply
79
+ // otherwise (real emulators/simulators often need longer connection/wait timeouts than the defaults).
80
+ if (config.connectionRetryTimeout !== undefined)
81
+ wdio.connectionRetryTimeout = config.connectionRetryTimeout;
82
+ if (config.connectionRetryCount !== undefined)
83
+ wdio.connectionRetryCount = config.connectionRetryCount;
84
+ if (config.waitforTimeout !== undefined)
85
+ wdio.waitforTimeout = config.waitforTimeout;
86
+ if (config.bail !== undefined)
87
+ wdio.bail = config.bail;
88
+ if (config.logLevel !== undefined)
89
+ wdio.logLevel = config.logLevel;
90
+ return wdio;
67
91
  }
68
92
  const CONFIG_NAMES = [
69
93
  "nativeproof.config.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nativeproof",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Native Mobile E2E test framework inspired by Playwright (fixtures, locators, expect, route-style mocking) on Appium/WebdriverIO.",