@dever-labs/mockly-driver 0.7.0 → 0.8.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 +18 -18
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# mockly-driver
|
|
1
|
+
# @dever-labs/mockly-driver
|
|
2
2
|
|
|
3
3
|
Node.js client for [Mockly](https://github.com/dever-labs/mockly) — start, stop, and control Mockly HTTP mock servers from Node.js test suites.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import { MocklyServer } from 'mockly-driver'
|
|
6
|
+
import { MocklyServer } from '@dever-labs/mockly-driver'
|
|
7
7
|
|
|
8
|
-
const server = await MocklyServer.ensure() //
|
|
8
|
+
const server = await MocklyServer.ensure() // download binary if needed, then start
|
|
9
9
|
|
|
10
10
|
await server.addMock({
|
|
11
11
|
id: 'get-users',
|
|
@@ -22,17 +22,15 @@ await server.stop()
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
|
-
npm install --save-dev mockly-driver
|
|
25
|
+
npm install --save-dev @dever-labs/mockly-driver
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
The Mockly binary is
|
|
28
|
+
The Mockly binary is downloaded automatically for your platform when you run `npm install`. You can also trigger it manually:
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
|
-
npx mockly-
|
|
31
|
+
npx mockly-install
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Or let `MocklyServer.ensure()` handle it automatically on first run.
|
|
35
|
-
|
|
36
34
|
---
|
|
37
35
|
|
|
38
36
|
## Usage
|
|
@@ -57,7 +55,7 @@ const server = await MocklyServer.create()
|
|
|
57
55
|
|
|
58
56
|
```ts
|
|
59
57
|
// vitest / jest
|
|
60
|
-
import { MocklyServer } from 'mockly-driver'
|
|
58
|
+
import { MocklyServer } from '@dever-labs/mockly-driver'
|
|
61
59
|
|
|
62
60
|
let server: MocklyServer
|
|
63
61
|
|
|
@@ -167,16 +165,18 @@ await server.clearFault()
|
|
|
167
165
|
|
|
168
166
|
## Binary installation
|
|
169
167
|
|
|
170
|
-
|
|
168
|
+
The binary is downloaded automatically on `npm install` via a postinstall script. The version downloaded always matches the npm package version.
|
|
169
|
+
|
|
170
|
+
### Manual install
|
|
171
171
|
|
|
172
172
|
```sh
|
|
173
|
-
npx mockly-
|
|
173
|
+
npx mockly-install
|
|
174
174
|
```
|
|
175
175
|
|
|
176
176
|
Or programmatically:
|
|
177
177
|
|
|
178
178
|
```ts
|
|
179
|
-
import { install } from 'mockly-driver'
|
|
179
|
+
import { install } from '@dever-labs/mockly-driver'
|
|
180
180
|
await install()
|
|
181
181
|
```
|
|
182
182
|
|
|
@@ -186,7 +186,7 @@ Set `MOCKLY_DOWNLOAD_BASE_URL` to your mirror's base URL (the path up to and inc
|
|
|
186
186
|
|
|
187
187
|
```sh
|
|
188
188
|
MOCKLY_DOWNLOAD_BASE_URL=https://artifactory.company.com/artifactory/github-releases/dever-labs/mockly/releases/download \
|
|
189
|
-
npx mockly-
|
|
189
|
+
npx mockly-install
|
|
190
190
|
```
|
|
191
191
|
|
|
192
192
|
Artifactory setup: create a **Generic Remote Repository** pointing to `https://github.com` and enable "Store Artifacts Locally". The download URL then becomes `https://<artifactory>/artifactory/<repo>/dever-labs/mockly/releases/download`.
|
|
@@ -196,12 +196,12 @@ Artifactory setup: create a **Generic Remote Repository** pointing to `https://g
|
|
|
196
196
|
Set `HTTPS_PROXY` or `HTTP_PROXY` before running the install:
|
|
197
197
|
|
|
198
198
|
```sh
|
|
199
|
-
HTTPS_PROXY=https://proxy.company.com:3128 npx mockly-
|
|
199
|
+
HTTPS_PROXY=https://proxy.company.com:3128 npx mockly-install
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
Proxy authentication is supported via the proxy URL: `https://user:pass@proxy:3128`.
|
|
203
203
|
|
|
204
|
-
> **Note:** If your proxy username or password contains special characters (e.g. `@`, `:`, `/`), URL-encode them first — e.g. `p@ss` → `p%40ss`.
|
|
204
|
+
> **Note:** If your proxy username or password contains special characters (e.g. `@`, `:`, `/`), URL-encode them first — e.g. `p@ss` → `p%40ss`.
|
|
205
205
|
|
|
206
206
|
> **Tip:** For Artifactory, `MOCKLY_DOWNLOAD_BASE_URL` is simpler and more reliable than `HTTPS_PROXY`.
|
|
207
207
|
|
|
@@ -211,13 +211,13 @@ Pre-stage the binary and point to it:
|
|
|
211
211
|
|
|
212
212
|
```sh
|
|
213
213
|
# On a machine with internet access:
|
|
214
|
-
npx mockly-
|
|
214
|
+
npx mockly-install
|
|
215
215
|
|
|
216
216
|
# Copy bin/mockly[.exe] to the air-gapped machine, then:
|
|
217
217
|
MOCKLY_BINARY_PATH=/opt/tools/mockly npx vitest run
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
Or set `MOCKLY_NO_INSTALL=true` to make
|
|
220
|
+
Or set `MOCKLY_NO_INSTALL=true` to make a missing binary a hard error:
|
|
221
221
|
|
|
222
222
|
```sh
|
|
223
223
|
MOCKLY_NO_INSTALL=true npx vitest run # fails fast if binary not staged
|
|
@@ -229,7 +229,7 @@ MOCKLY_NO_INSTALL=true npx vitest run # fails fast if binary not staged
|
|
|
229
229
|
|---|---|
|
|
230
230
|
| `MOCKLY_BINARY_PATH` | Absolute path to a pre-existing binary. Skips all download logic. |
|
|
231
231
|
| `MOCKLY_DOWNLOAD_BASE_URL` | Base URL override for binary downloads (Artifactory / mirrors). |
|
|
232
|
-
| `MOCKLY_VERSION` | Binary version to install.
|
|
232
|
+
| `MOCKLY_VERSION` | Binary version to install. Defaults to the installed package version. |
|
|
233
233
|
| `MOCKLY_NO_INSTALL` | If set, fail with instructions instead of downloading. |
|
|
234
234
|
| `HTTPS_PROXY` / `HTTP_PROXY` | Route downloads through an HTTP proxy (supports CONNECT). |
|
|
235
235
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dever-labs/mockly-driver",
|
|
3
|
-
"version": "v0.
|
|
3
|
+
"version": "v0.8.1",
|
|
4
4
|
"description": "Node.js client for Mockly — start/stop servers and manage HTTP mocks in tests",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mock",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"js-yaml": "^4.1.0"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@dever-labs/mockly-driver-linux-x64": "v0.
|
|
55
|
-
"@dever-labs/mockly-driver-linux-arm64": "v0.
|
|
56
|
-
"@dever-labs/mockly-driver-darwin-x64": "v0.
|
|
57
|
-
"@dever-labs/mockly-driver-darwin-arm64": "v0.
|
|
58
|
-
"@dever-labs/mockly-driver-win32-x64": "v0.
|
|
54
|
+
"@dever-labs/mockly-driver-linux-x64": "v0.8.1",
|
|
55
|
+
"@dever-labs/mockly-driver-linux-arm64": "v0.8.1",
|
|
56
|
+
"@dever-labs/mockly-driver-darwin-x64": "v0.8.1",
|
|
57
|
+
"@dever-labs/mockly-driver-darwin-arm64": "v0.8.1",
|
|
58
|
+
"@dever-labs/mockly-driver-win32-x64": "v0.8.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/js-yaml": "^4.0.9",
|