kempo-testing-framework 1.2.0 → 1.2.2

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/index.js CHANGED
@@ -10,7 +10,8 @@ const shortFlagMap = {
10
10
  'd': 'delay',
11
11
  'p': 'port',
12
12
  'g': 'gui',
13
- 'w': 'show-browser'
13
+ 'w': 'show-browser',
14
+ 'h': 'help'
14
15
  };
15
16
 
16
17
  /*
@@ -22,7 +23,7 @@ const remainingArgs = [];
22
23
 
23
24
  // Define which flags take values vs booleans
24
25
  const valueFlags = new Set(['log-level', 'delay', 'port']);
25
- const booleanFlags = new Set(['browser', 'node', 'gui', 'show-browser']);
26
+ const booleanFlags = new Set(['browser', 'node', 'gui', 'show-browser', 'help', 'debug-flags']);
26
27
 
27
28
  for (let i = 0; i < args.length; i++) {
28
29
  const arg = args[i];
@@ -108,6 +109,48 @@ if (Object.prototype.hasOwnProperty.call(flags, 'log-level')) {
108
109
  delete flags['log-level'];
109
110
  }
110
111
 
112
+ /*
113
+ * Help Display
114
+ */
115
+ if (flags.help || flags.h) {
116
+ console.log(`
117
+ Kempo Testing Framework
118
+
119
+ USAGE:
120
+ kempo-test [OPTIONS] [SUITE_FILTER] [TEST_FILTER]
121
+
122
+ OPTIONS:
123
+ -h, --help Show this help message and exit
124
+ -b, --browser Run only browser tests
125
+ -n, --node Run only node tests
126
+ -l, --log-level LEVEL Set log level (0-4 or silent/minimal/normal/verbose/debug)
127
+ -d, --delay MS Add delay between tests in milliseconds
128
+ -p, --port PORT Set port for test server (default: 3000)
129
+ -g, --gui Launch GUI mode
130
+ -w, --show-browser Show browser window during tests
131
+
132
+ ARGUMENTS:
133
+ SUITE_FILTER Filter test suites by name
134
+ TEST_FILTER Filter individual tests by name
135
+
136
+ EXAMPLES:
137
+ kempo-test # Run all tests
138
+ kempo-test --browser # Run only browser tests
139
+ kempo-test -l verbose # Run with verbose logging
140
+ kempo-test --gui # Launch GUI mode
141
+ kempo-test myComponent # Run tests for 'myComponent' suite
142
+ kempo-test myComponent myTest # Run specific test in specific suite
143
+ `);
144
+ process.exit(0);
145
+ }
146
+
147
+ /*
148
+ * Debug Flags (for testing only)
149
+ */
150
+ if (flags['debug-flags']) {
151
+ console.log('kempo-test flags:', flags);
152
+ }
153
+
111
154
  /*
112
155
  * Mode Selection and Execution
113
156
  */
@@ -115,8 +158,6 @@ if (flags.gui) {
115
158
  const { default: gui } = await import('./src/gui.js');
116
159
  await gui(flags, remainingArgs);
117
160
  } else {
118
- // Log flags to verify capture
119
- console.log('kempo-test flags:', flags);
120
161
  const { default: cli } = await import('./src/cli.js');
121
162
  await cli(flags, remainingArgs);
122
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo-testing-framework",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "The Kempo Testing Framework is a simple testing framework built on the principle that code intended to be ran in the browser should be tested in the browser, code intended to be ran in Node should be tested in Node, and code intended to be ran in both should be tested in both. No mocking, no complexity—just testing.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -48,6 +48,14 @@ export default async ({
48
48
  await page.goto(`${url}?testFile=${testFile}&testFilter=${filter}&delay=${delayMs}`);
49
49
  await page.waitForFunction(() => document.readyState === 'complete' || document.readyState === 'interactive');
50
50
 
51
+ // Ensure the test page has focus when browser is visible
52
+ if (showBrowser) {
53
+ await page.bringToFront();
54
+ if (logLevel >= LOG_LEVELS.VERBOSE) {
55
+ console.log(`\x1b[90m Bringing test page to front\x1b[0m`);
56
+ }
57
+ }
58
+
51
59
  // Check for any errors first
52
60
  const hasError = await page.evaluate(() => window.error !== undefined);
53
61
  if (hasError) {
@@ -1,7 +1,7 @@
1
1
  import { spawn } from 'child_process';
2
2
 
3
3
  const runWithArgs = (args, timeoutMs = 3000) => new Promise((resolve) => {
4
- const child = spawn(process.execPath, ['index.js', ...args], {
4
+ const child = spawn(process.execPath, ['index.js', ...args, '--debug-flags'], {
5
5
  cwd: process.cwd(),
6
6
  stdio: ['ignore', 'pipe', 'pipe']
7
7
  });
@@ -0,0 +1,61 @@
1
+ import { spawn } from 'child_process';
2
+
3
+ const runWithHelp = (args, timeoutMs = 3000) => new Promise((resolve) => {
4
+ const child = spawn(process.execPath, ['index.js', ...args], {
5
+ cwd: process.cwd(),
6
+ stdio: ['ignore', 'pipe', 'pipe']
7
+ });
8
+ let out = '';
9
+ let resolved = false;
10
+
11
+ const finish = () => {
12
+ if (resolved) return;
13
+ resolved = true;
14
+ try { child.kill('SIGTERM'); } catch {}
15
+ resolve(out);
16
+ };
17
+
18
+ child.stdout.on('data', (chunk) => {
19
+ out += chunk.toString();
20
+ // Help should exit quickly, check for help content
21
+ if (out.includes('Kempo Testing Framework') && out.includes('USAGE:')) {
22
+ setTimeout(finish, 50);
23
+ }
24
+ });
25
+ child.stderr.on('data', (chunk) => { out += chunk.toString(); });
26
+ child.on('error', () => finish());
27
+ child.on('exit', () => finish());
28
+
29
+ setTimeout(finish, timeoutMs);
30
+ });
31
+
32
+ export default {
33
+ '--help shows help message and exits': async ({ pass, fail }) => {
34
+ const out = await runWithHelp(['--help']);
35
+ const hasHelp = out.includes('Kempo Testing Framework') &&
36
+ out.includes('USAGE:') &&
37
+ out.includes('OPTIONS:') &&
38
+ out.includes('--help');
39
+ const noTestRun = !out.includes('kempo-test flags:') && !out.includes('Test Summary');
40
+
41
+ if (hasHelp && noTestRun) {
42
+ pass('--help shows help message and exits without running tests');
43
+ } else {
44
+ fail(`Help output incorrect:\nHas help: ${hasHelp}\nNo test run: ${noTestRun}\nOutput:\n${out}`);
45
+ }
46
+ },
47
+ '-h shows help message and exits': async ({ pass, fail }) => {
48
+ const out = await runWithHelp(['-h']);
49
+ const hasHelp = out.includes('Kempo Testing Framework') &&
50
+ out.includes('USAGE:') &&
51
+ out.includes('OPTIONS:') &&
52
+ out.includes('--help');
53
+ const noTestRun = !out.includes('kempo-test flags:') && !out.includes('Test Summary');
54
+
55
+ if (hasHelp && noTestRun) {
56
+ pass('-h shows help message and exits without running tests');
57
+ } else {
58
+ fail(`Help output incorrect:\nHas help: ${hasHelp}\nNo test run: ${noTestRun}\nOutput:\n${out}`);
59
+ }
60
+ }
61
+ };