You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner. It is now read-only.
This solution provides you commands for easily changing [@mocks-serversettings][mocks-server-options-url], such as current behavior, delay time, etc.
10
+
Extends Cypress' cy commands with methods for easily changing [Mocks Server settings][mocks-server-options-url], such as current mock, route variants, delay time, etc.
11
11
12
12
## Installation
13
13
@@ -31,51 +31,52 @@ You can now use all next commands:
31
31
32
32
### Commands
33
33
34
-
Set current behavior:
34
+
##### `cy.mocksSetMock("users-error")`
35
35
36
-
```js
37
-
cy.mocksServerSetBehavior("admin-user");
38
-
```
36
+
Sets current mock.
39
37
40
-
Set delay time:
38
+
##### `cy.mocksUseRouteVariant("users:success")`
41
39
42
-
```js
43
-
cy.mocksServerSetDelay(2000);
44
-
```
40
+
Sets a specific route variant to be used by current mock.
45
41
46
-
Set any setting:
42
+
##### `cy.mocksRestoreRoutesVariants()`
47
43
48
-
```js
49
-
cy.mocksServerSetSettings({
50
-
watch:false,
51
-
delay:0,
52
-
behavior:"catalog-error"
53
-
});
54
-
```
44
+
Restore routes variants to those defined in current mock.
55
45
56
-
##Configuration
46
+
##### `cy.mocksSetDelay(2000)`
57
47
58
-
By default, the client is configured to request to http://localhost:3100/admin, based in the [default options of @mocks-server][mocks-server-options-url]
48
+
Sets delay time.
59
49
60
-
You can change both the base url of the "@mocks-server", and the admin api path of the "@mocks-server/plugin-admin-api" using the `config` method in your project's `cypress/support/commands.js`:
Configures the [Mocks Server administration API client](https://github.com/mocks-server/admin-api-client), used under the hood.
57
+
58
+
##### `cy.mocksSetBehavior("foo")`
59
+
60
+
Legacy method that sets behavior in Mocks Server v1.x
61
+
62
+
## Configuration
63
+
64
+
By default, the API client is configured to request to `http://localhost:3100/admin`, based in the [default Mocks Server options][mocks-server-options-url]
65
+
66
+
You can change both the base url of Mocks Server, and the api path of the administration API using the `cy.mocksConfig` command mentioned above, or the plugin environment variables:
67
+
68
+
*__`MOCKS_SERVER_BASE_URL`__: Modifies the base url of Mocks Server. Default is `http://localhost:3100`.
69
+
*__`MOCKS_SERVER_ADMIN_API_PATH`__: Modifies the path of the Mocks Server administration API. Default is `/admin`.
70
+
*__`MOCKS_SERVER_ENABLED`__: Disables requests to Mocks Server, so the commands will not fail even when Mocks Server is not running. This is useful to reuse same tests with mocks and a real API, because commands to change Mocks Server settings will be ignored.
70
71
71
72
### Using commands
72
73
73
-
You should usually change the mock server settings in a `before` statement:
74
+
You should usually change Mocks Server settings in a `before` statement:
0 commit comments