@opra/testing 1.28.3 → 1.28.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/LICENSE +1 -1
- package/README.md +58 -3
- package/package.json +5 -4
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,19 +1,74 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<a href="https://oprajs.com">
|
|
4
|
+
<img src="https://oprajs.com/img/opra-header-block.webp" width="880" alt="OPRA — Open Platform for Rich APIs" />
|
|
5
|
+
</a>
|
|
6
|
+
|
|
1
7
|
# @opra/testing
|
|
2
8
|
|
|
9
|
+
Testing utilities for the OPRA framework
|
|
10
|
+
|
|
3
11
|
[![NPM Version][npm-image]][npm-url]
|
|
4
12
|
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
13
|
[![CI Tests][ci-test-image]][ci-test-url]
|
|
6
14
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
15
|
|
|
16
|
+
[🌐 Documentation](https://oprajs.com) · [🚀 Getting Started](https://oprajs.com/docs/introduction) · [📦 Packages](https://github.com/panates/opra#packages) · [💬 Issues](https://github.com/panates/opra/issues)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
Testing utilities for the [OPRA](https://oprajs.com) framework. Write clean, expressive API tests with a fluent assertion API designed for OPRA services.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **`OpraTestClient`** — Test client that accepts an HTTP server or request listener directly — no running server needed
|
|
27
|
+
- **`ApiExpect`** — Chainable assertion class for response validation
|
|
28
|
+
- **`TestBackend`** — Lightweight fetch-based backend for test requests
|
|
29
|
+
- Works with any test runner (Jest, Vitest, Mocha, etc.)
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
8
32
|
|
|
9
|
-
|
|
10
|
-
|
|
33
|
+
```bash
|
|
34
|
+
npm install --save-dev @opra/testing
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { OpraTestClient } from '@opra/testing';
|
|
41
|
+
|
|
42
|
+
describe('UsersController', () => {
|
|
43
|
+
let client: OpraTestClient;
|
|
44
|
+
|
|
45
|
+
beforeAll(() => {
|
|
46
|
+
client = new OpraTestClient(app);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return users', async () => {
|
|
50
|
+
await client
|
|
51
|
+
.get('/users')
|
|
52
|
+
.expect(200)
|
|
53
|
+
.toSuccess()
|
|
54
|
+
.toMatchSchema(User);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should return 404 for unknown user', async () => {
|
|
58
|
+
await client
|
|
59
|
+
.get('/users/999')
|
|
60
|
+
.expect(404)
|
|
61
|
+
.toError('NotFound');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
```
|
|
11
65
|
|
|
12
66
|
## Node Compatibility
|
|
13
|
-
- node >= 20.x
|
|
14
67
|
|
|
68
|
+
- node >= 20.x
|
|
15
69
|
|
|
16
70
|
## License
|
|
71
|
+
|
|
17
72
|
Available under [MIT](LICENSE) license.
|
|
18
73
|
|
|
19
74
|
[npm-image]: https://img.shields.io/npm/v/@opra/testing
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/testing",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.5",
|
|
4
4
|
"description": "Opra testing package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"homepage": "https://www.oprajs.com",
|
|
7
8
|
"dependencies": {
|
|
8
9
|
"@browsery/type-is": "^2.0.2-r1",
|
|
9
|
-
"@jsopen/objects": "^2.2.
|
|
10
|
+
"@jsopen/objects": "^2.2.2",
|
|
10
11
|
"ansi-colors": "^4.1.3",
|
|
11
12
|
"rule-judgment": "^1.1.5",
|
|
12
13
|
"tslib": "^2.8.1"
|
|
13
14
|
},
|
|
14
15
|
"peerDependencies": {
|
|
15
|
-
"@opra/client": "^1.28.
|
|
16
|
-
"@opra/common": "^1.28.
|
|
16
|
+
"@opra/client": "^1.28.5",
|
|
17
|
+
"@opra/common": "^1.28.5",
|
|
17
18
|
"expect": "^29.0.0 || ^30.0.0",
|
|
18
19
|
"jest-matcher-utils": "^29.0.0 || ^30.0.0"
|
|
19
20
|
},
|