Skip to content
This repository has been archived by the owner. It is now read-only.

Commit cbf22f1

Browse files
authored
Merge pull request #153 from mocks-server/release
Release v2.0.0
2 parents 7ca4cf9 + 46c613b commit cbf22f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+973
-2665
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"env": {
3-
"node": true
3+
"node": true,
4+
"es6": true
45
},
56
"parserOptions": {
67
"ecmaVersion": "2018"

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- release
7+
- pre-release
78
pull_request:
89
jobs:
910
test:

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,52 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
### Changed
1010
### Fixed
1111
### Removed
12+
### Breaking changes
13+
14+
## [2.0.0] - 2021-02-17
15+
16+
### Added
17+
- feat: Add `mocksConfig`, `mocksSetMock`, `mocksUseRouteVariant` and `mocksRestoreRoutesVariants` commands
18+
- feat: Add support for environment variables `MOCKS_SERVER_ENABLED`, `MOCKS_SERVER_BASE_URL` and `MOCKS_SERVER_ADMIN_API_PATH` (#3)
19+
20+
### Changed
21+
- feat: Rename `mocksServerSetBehavior` command to `mocksSetBehavior`
22+
- feat: Rename `mocksServerSetDelay` command to `mocksSetDelay`
23+
- feat: Rename `mocksServerSetSettings` command to `mocksSetSettings`
24+
- chore(deps): Update dependencies to mocks-server v2 compatible versions
25+
- chore(deps): Update Cypress to v6 in tests
26+
27+
### Removed
28+
- feat: Remove `config` method, `cy.mocksConfig` command should be used instead
29+
- test(e2e): Remove e2e tests using data-provider, as it does not concern to this package
30+
31+
### Breaking changes
32+
- Rename `mocksServerSetBehavior` command to `mocksSetBehavior`
33+
- Rename `mocksServerSetDelay` command to `mocksSetDelay`
34+
- Rename `mocksServerSetSettings` command to `mocksSetSettings`
35+
- Remove `config` method, `cy.mocksConfig` command should be used instead
36+
37+
## [2.0.0-beta.1] - 2021-02-16
38+
39+
### Added
40+
- feat: Add `mocksConfig`, `mocksSetMock`, `mocksUseRouteVariant` and `mocksRestoreRoutesVariants` commands
41+
- feat: Add support for environment variables `MOCKS_SERVER_ENABLED`, `MOCKS_SERVER_BASE_URL` and `MOCKS_SERVER_ADMIN_API_PATH` (#3)
42+
43+
### Changed
44+
- feat: Rename `mocksServerSetBehavior` command to `mocksSetBehavior`
45+
- feat: Rename `mocksServerSetDelay` command to `mocksSetDelay`
46+
- feat: Rename `mocksServerSetSettings` command to `mocksSetSettings`
47+
- chore(deps): Update dependencies to mocks-server v2 compatible versions
48+
49+
### Removed
50+
- feat: Remove `config` method, `cy.mocksConfig` command should be used instead
51+
- test(e2e): Remove e2e tests using data-provider, as it does not concern to this package
52+
53+
### Breaking changes
54+
- Rename `mocksServerSetBehavior` command to `mocksSetBehavior`
55+
- Rename `mocksServerSetDelay` command to `mocksSetDelay`
56+
- Rename `mocksServerSetSettings` command to `mocksSetSettings`
57+
- Remove `config` method, `cy.mocksConfig` command should be used instead
1258

1359
## [1.0.8] - 2020-12-21
1460

README.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
[![NPM downloads][npm-downloads-image]][npm-downloads-url] [![License][license-image]][license-url]
66

77

8-
# Mocks server Cypress commands
8+
# Mocks Server Cypress commands
99

10-
This solution provides you commands for easily changing [@mocks-server settings][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.
1111

1212
## Installation
1313

@@ -31,51 +31,52 @@ You can now use all next commands:
3131

3232
### Commands
3333

34-
Set current behavior:
34+
##### `cy.mocksSetMock("users-error")`
3535

36-
```js
37-
cy.mocksServerSetBehavior("admin-user");
38-
```
36+
Sets current mock.
3937

40-
Set delay time:
38+
##### `cy.mocksUseRouteVariant("users:success")`
4139

42-
```js
43-
cy.mocksServerSetDelay(2000);
44-
```
40+
Sets a specific route variant to be used by current mock.
4541

46-
Set any setting:
42+
##### `cy.mocksRestoreRoutesVariants()`
4743

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.
5545

56-
## Configuration
46+
##### `cy.mocksSetDelay(2000)`
5747

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.
5949

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`:
50+
##### `cy.mocksSetSettings({ watch: false, delay: 0 })`
6151

62-
```js
63-
import { config } from "@mocks-server/cypress-commands";
52+
Sets any [Mocks Server setting][mocks-server-options-url].
6453

65-
config({
66-
adminApiPath: "/foo-admin",
67-
baseUrl: "http://my-mocks-server:3200"
68-
});
69-
```
54+
##### `cy.mocksConfig({ adminApiPath: "/foo", baseUrl: "http://localhost:3000" })`
55+
56+
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.
7071

7172
### Using commands
7273

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:
7475

7576
```js
7677
describe("user with default role", () => {
7778
before(() => {
78-
cy.mocksServerSetBehavior("normal-user");
79+
cy.mocksSetMock("normal-user");
7980
cy.visit("/");
8081
});
8182

@@ -86,7 +87,7 @@ describe("user with default role", () => {
8687

8788
describe("user with admin role", () => {
8889
before(() => {
89-
cy.mocksServerSetBehavior("admin-user");
90+
cy.mocksSetMock("admin-user");
9091
cy.visit("/");
9192
});
9293

index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
/* global Cypress */
22

3-
const { config } = require("./src/commands");
43
const register = require("./src/register");
54

65
register(Cypress);
7-
8-
module.exports = {
9-
config,
10-
};

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ module.exports = {
2525
},
2626

2727
// The glob patterns Jest uses to detect test files
28-
testMatch: ["**/test/**/?(*.)+(spec|test).js?(x)"],
28+
testMatch: ["<rootDir>/test/**/*.spec.js"],
29+
// testMatch: ["<rootDir>/test/**/commands.spec.js"],
2930

3031
// The test environment that will be used for testing
3132
testEnvironment: "node",

0 commit comments

Comments
 (0)