kempo-testing-framework 1.4.3 → 1.4.5
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/llm.txt +61 -0
- package/package.json +2 -2
- package/.github/copilot-instructions.md +0 -105
- package/src/utils/fibonacci.js +0 -0
- /package/{CONTRIBUTING.md → AGENTS.md} +0 -0
package/llm.txt
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Kempo Testing Framework
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
`npm install kempo-testing-framework --save-dev`
|
|
5
|
+
|
|
6
|
+
## Test File Naming
|
|
7
|
+
- `name.browser-test.js` — browser only
|
|
8
|
+
- `name.node-test.js` — Node only
|
|
9
|
+
- `name.test.js` — both environments
|
|
10
|
+
|
|
11
|
+
Place files anywhere under `tests/` (recursive discovery).
|
|
12
|
+
|
|
13
|
+
## Test File Structure
|
|
14
|
+
```js
|
|
15
|
+
import yourModule from '../src/yourModule.js';
|
|
16
|
+
|
|
17
|
+
// Optional lifecycle exports (all async-capable, receive `log` function)
|
|
18
|
+
export const beforeAll = async (log) => {};
|
|
19
|
+
export const beforeEach = async (log) => {};
|
|
20
|
+
export const afterEach = async (log) => {};
|
|
21
|
+
export const afterAll = async (log) => {};
|
|
22
|
+
|
|
23
|
+
// Optional: custom HTML page for browser tests (path relative to test file)
|
|
24
|
+
export const page = './custom-page.html';
|
|
25
|
+
|
|
26
|
+
// Required: default export is an object of named tests
|
|
27
|
+
export default {
|
|
28
|
+
'test name': ({ pass, fail, log }) => {
|
|
29
|
+
// log(msg) — emit a log message
|
|
30
|
+
// pass(msg) — mark test passed
|
|
31
|
+
// fail(msg) — mark test failed
|
|
32
|
+
pass('ok');
|
|
33
|
+
},
|
|
34
|
+
'async test': async ({ pass, fail, log }) => {
|
|
35
|
+
const result = await yourModule.fn();
|
|
36
|
+
result === 'expected' ? pass('ok') : fail(`got ${result}`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## CLI
|
|
42
|
+
```
|
|
43
|
+
npx kempo-test # run all tests
|
|
44
|
+
npx kempo-test -b # browser only
|
|
45
|
+
npx kempo-test -n # node only
|
|
46
|
+
npx kempo-test --gui # start web GUI
|
|
47
|
+
npx kempo-test auth # filter files by substring
|
|
48
|
+
npx kempo-test auth login # filter files then tests by substring
|
|
49
|
+
npx kempo-test -b auth login # combined
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Key Flags
|
|
53
|
+
| Flag | Default | Description |
|
|
54
|
+
|------|---------|-------------|
|
|
55
|
+
| `-b` / `--browser` | — | Browser tests only |
|
|
56
|
+
| `-n` / `--node` | — | Node tests only |
|
|
57
|
+
| `-l` / `--log-level` | normal | silent\|minimal\|normal\|verbose\|debug (or 0–4) |
|
|
58
|
+
| `-p` / `--port` | 3000 | Browser test server port |
|
|
59
|
+
| `-w` / `--show-browser` | headless | Show browser window |
|
|
60
|
+
| `-d` / `--delay` | 0 | ms pause before/after browser tests (requires -w) |
|
|
61
|
+
| `-t` / `--timeout` | 30000 | Per-test timeout in ms (min 1000) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo-testing-framework",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
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": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"kempo-css": "^1.3.
|
|
18
|
+
"kempo-css": "^1.3.13",
|
|
19
19
|
"puppeteer": "^24.9.0"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Code Contribution Guidelines
|
|
2
|
-
|
|
3
|
-
## Project Structure
|
|
4
|
-
|
|
5
|
-
- All code should be in the `src/` directory, with the exception of index.js.
|
|
6
|
-
- All utility function module files should be in the `src/utils/` directory.
|
|
7
|
-
|
|
8
|
-
### GUI
|
|
9
|
-
|
|
10
|
-
All files served by the GUI should be in the `gui/` directory, with the exception of scripts shared with the CLI, custom endpoints, and node_modules like kempo.css (which should have custom endpoints).
|
|
11
|
-
|
|
12
|
-
## Coding Style Guidelines
|
|
13
|
-
|
|
14
|
-
### Code Organization
|
|
15
|
-
Use multi-line comments to separate code into logical sections. Group related functionality together.
|
|
16
|
-
- Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
/*
|
|
20
|
-
Lifecycle Callbacks
|
|
21
|
-
*/
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Avoid single-use variables/functions
|
|
25
|
-
Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
|
|
26
|
-
- recursion
|
|
27
|
-
- scope encapsulation (IIFE)
|
|
28
|
-
- context changes
|
|
29
|
-
|
|
30
|
-
### Minimal Comments, Empty Lines, and Spacing
|
|
31
|
-
|
|
32
|
-
Use minimal comments. Assume readers understand the language. Some exceptions include:
|
|
33
|
-
- complex logic
|
|
34
|
-
- anti-patterns
|
|
35
|
-
- code organization
|
|
36
|
-
|
|
37
|
-
Do not put random empty lines within code; put them where they make sense for readability, for example:
|
|
38
|
-
- above and below definitions for functions and classes.
|
|
39
|
-
- to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
|
|
40
|
-
- above multi-line comments to indicate the comment belongs to the code below
|
|
41
|
-
|
|
42
|
-
No empty lines in css.
|
|
43
|
-
|
|
44
|
-
End each file with an empty line.
|
|
45
|
-
|
|
46
|
-
End each line with a `;` when possible, even if it is optional.
|
|
47
|
-
|
|
48
|
-
Avoid unnecessary spacing, for example:
|
|
49
|
-
- after the word `if`
|
|
50
|
-
- within parentheses for conditional statements
|
|
51
|
-
|
|
52
|
-
```javascript
|
|
53
|
-
let count = 1;
|
|
54
|
-
|
|
55
|
-
const incrementOdd = (n) => {
|
|
56
|
-
if(n % 2 !== 0){
|
|
57
|
-
return n++;
|
|
58
|
-
}
|
|
59
|
-
return n;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
count = incrementOdd(count);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Prefer Arrow Functions
|
|
66
|
-
Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
|
|
67
|
-
- For very basic logic, use implicit returns
|
|
68
|
-
- If there is a single parameter, omit the parentheses.
|
|
69
|
-
```javascript
|
|
70
|
-
const addOne = n => n + 1;
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Module Exports
|
|
74
|
-
- If a module has only one export, use the "default" export, not a named export.
|
|
75
|
-
- Do not declare the default export as a const or give it a name; just export the value.
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
export default (n) => n + 1;
|
|
79
|
-
```
|
|
80
|
-
- If a module has multiple exports, use named exports and do not use a "default" export.
|
|
81
|
-
|
|
82
|
-
### Code Reuse
|
|
83
|
-
Create utility functions for shared logic.
|
|
84
|
-
- If the shared logic is used in a single file, define a utility function in that file.
|
|
85
|
-
- If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
|
|
86
|
-
|
|
87
|
-
### Naming
|
|
88
|
-
Do not prefix identifiers with underscores.
|
|
89
|
-
- Never use leading underscores (`_`) for variable, property, method, or function names.
|
|
90
|
-
- Use clear, descriptive names without prefixes.
|
|
91
|
-
- When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
|
|
92
|
-
|
|
93
|
-
## Lit Components
|
|
94
|
-
|
|
95
|
-
### Component Architecture and Communication
|
|
96
|
-
|
|
97
|
-
- Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
|
|
98
|
-
- Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
|
|
99
|
-
|
|
100
|
-
- Wrap dependent GUI components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
|
|
101
|
-
|
|
102
|
-
- Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
|
|
103
|
-
|
|
104
|
-
- Queued status must show the `scheduled` icon. Running may apply `animation="spin"`.
|
|
105
|
-
|
package/src/utils/fibonacci.js
DELETED
|
File without changes
|
|
File without changes
|