@robinpath/assert 0.1.0 → 0.1.1
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/README.md +98 -0
- package/package.json +25 -7
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @robinpath/assert
|
|
2
|
+
|
|
3
|
+
> Testing assertions: equal, deepEqual, truthy, falsy, type checks, includes, matches, throws, and more
|
|
4
|
+
|
|
5
|
+
   
|
|
6
|
+
|
|
7
|
+
## Why use this module?
|
|
8
|
+
|
|
9
|
+
The `assert` module lets you:
|
|
10
|
+
|
|
11
|
+
- Assert two values are strictly equal (===)
|
|
12
|
+
- Assert two values are not equal
|
|
13
|
+
- Assert deep equality of two values
|
|
14
|
+
- Assert value is truthy
|
|
15
|
+
- Assert value is falsy
|
|
16
|
+
|
|
17
|
+
All functions are callable directly from RobinPath scripts with a simple, consistent API.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @robinpath/assert
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
No credentials needed — start using it right away:
|
|
28
|
+
|
|
29
|
+
```robinpath
|
|
30
|
+
assert.notEqual $a $b
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Available Functions
|
|
34
|
+
|
|
35
|
+
| Function | Description |
|
|
36
|
+
|----------|-------------|
|
|
37
|
+
| `assert.equal` | Assert two values are strictly equal (===) |
|
|
38
|
+
| `assert.notEqual` | Assert two values are not equal |
|
|
39
|
+
| `assert.deepEqual` | Assert deep equality of two values |
|
|
40
|
+
| `assert.truthy` | Assert value is truthy |
|
|
41
|
+
| `assert.falsy` | Assert value is falsy |
|
|
42
|
+
| `assert.isNull` | Assert value is null or undefined |
|
|
43
|
+
| `assert.isNotNull` | Assert value is not null/undefined |
|
|
44
|
+
| `assert.isType` | Assert typeof value matches expected type |
|
|
45
|
+
| `assert.includes` | Assert array/string includes a value |
|
|
46
|
+
| `assert.matches` | Assert string matches a regex pattern |
|
|
47
|
+
| `assert.throws` | Assert that a function throws |
|
|
48
|
+
| `assert.lengthOf` | Assert array/string has specific length |
|
|
49
|
+
| `assert.hasProperty` | Assert object has a specific property |
|
|
50
|
+
| `assert.isAbove` | Assert number is above threshold |
|
|
51
|
+
| `assert.isBelow` | Assert number is below threshold |
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
### Assert two values are not equal
|
|
56
|
+
|
|
57
|
+
```robinpath
|
|
58
|
+
assert.notEqual $a $b
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Assert deep equality of two values
|
|
62
|
+
|
|
63
|
+
```robinpath
|
|
64
|
+
assert.deepEqual $obj1 $obj2
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Assert value is truthy
|
|
68
|
+
|
|
69
|
+
```robinpath
|
|
70
|
+
assert.truthy $val
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Integration with RobinPath
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { RobinPath } from "@wiredwp/robinpath";
|
|
77
|
+
import Module from "@robinpath/assert";
|
|
78
|
+
|
|
79
|
+
const rp = new RobinPath();
|
|
80
|
+
rp.registerModule(Module.name, Module.functions);
|
|
81
|
+
rp.registerModuleMeta(Module.name, Module.functionMetadata);
|
|
82
|
+
|
|
83
|
+
const result = await rp.executeScript(`
|
|
84
|
+
assert.notEqual $a $b
|
|
85
|
+
`);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Full API Reference
|
|
89
|
+
|
|
90
|
+
See [MODULE.md](./MODULE.md) for complete documentation including all parameters, return types, error handling, and advanced examples.
|
|
91
|
+
|
|
92
|
+
## Related Modules
|
|
93
|
+
|
|
94
|
+
- [`@robinpath/json`](../json) — JSON module for complementary functionality
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robinpath/assert",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"publishConfig": {
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
5
7
|
"type": "module",
|
|
6
8
|
"main": "dist/index.js",
|
|
7
9
|
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"test": "node --import tsx --test tests/*.test.ts"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@wiredwp/robinpath": ">=0.20.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@wiredwp/robinpath": "^0.30.1",
|
|
28
|
+
"tsx": "^4.19.0",
|
|
29
|
+
"typescript": "^5.6.0"
|
|
30
|
+
}
|
|
13
31
|
}
|