jest-matcher-http 1.4.2 → 1.4.4
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 +12 -13
- package/package.json +3 -17
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
Jest [matchers](https://jestjs.io/docs/using-matchers) (`
|
|
19
|
+
Jest [matchers](https://jestjs.io/docs/using-matchers) (`toReturnHttpCode`, `toReturnHttpHeader`) to [expect](https://jestjs.io/docs/expect) http responses.
|
|
20
20
|
|
|
21
21
|
Logs received body and headers if response is not as expected.
|
|
22
22
|
|
|
@@ -37,23 +37,22 @@ With npm:
|
|
|
37
37
|
$ npm install --save-dev jest-matcher-http
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
40
|
+
Add this package to your `jest.config.js`:
|
|
41
|
+
```
|
|
42
|
+
setupFilesAfterEnv: ['jest-matcher-http'],
|
|
43
|
+
```
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
Alternatively, if you need fine-grained control, load specific matchers in your test file:
|
|
46
|
+
```javascript
|
|
47
|
+
const { toReturnHttpCode } = require('jest-matcher-http');
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
expect.extend({ toReturnHttpCode });
|
|
50
|
+
```
|
|
52
51
|
|
|
53
52
|
# Usage
|
|
54
53
|
|
|
55
54
|
```javascript
|
|
56
|
-
expect(response).
|
|
55
|
+
expect(response).toReturnHttpCode(307);
|
|
57
56
|
expect(response).toReturnHttpHeader('Location', '/v1/new-path');
|
|
58
57
|
```
|
|
59
58
|
|
|
@@ -92,7 +91,7 @@ describe('Example', () => {
|
|
|
92
91
|
const response = await request
|
|
93
92
|
.get('/v1/old-path');
|
|
94
93
|
|
|
95
|
-
expect(response).
|
|
94
|
+
expect(response).toReturnHttpCode(307);
|
|
96
95
|
expect(response).toReturnHttpHeader('Location', '/v1/new-path');
|
|
97
96
|
})
|
|
98
97
|
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-matcher-http",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Additional Jest matchers for HTTP responses.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"lint": "eslint .",
|
|
8
8
|
"test": "jest --coverage --config jest.unit.config.js",
|
|
9
|
-
"acp": "git add . && npm run commit && git push",
|
|
10
|
-
"commit": "git-cz",
|
|
11
9
|
"semantic-release": "semantic-release --branches main"
|
|
12
10
|
},
|
|
13
11
|
"repository": {
|
|
@@ -38,32 +36,20 @@
|
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
40
38
|
"axios": "^1.2.1",
|
|
41
|
-
"commitizen": "^4.2.5",
|
|
42
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
43
39
|
"eslint": "^8.31.0",
|
|
44
40
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
45
|
-
"eslint-plugin-jest": "^27.2.
|
|
41
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
46
42
|
"eslint-plugin-jsdoc": "^39.6.4",
|
|
47
43
|
"express": "^4.18.2",
|
|
48
44
|
"http-terminator": "^3.2.0",
|
|
49
45
|
"jest": "^29.3.1",
|
|
50
46
|
"needle": "^3.2.0",
|
|
51
47
|
"pre-commit": "^1.2.2",
|
|
52
|
-
"semantic-release": "^
|
|
48
|
+
"semantic-release": "^20.0.2",
|
|
53
49
|
"signal-promise": "^1.0.3",
|
|
54
50
|
"superagent": "^8.0.5"
|
|
55
51
|
},
|
|
56
52
|
"dependencies": {
|
|
57
53
|
"@jest/globals": "^29.3.1"
|
|
58
|
-
},
|
|
59
|
-
"overrides": {
|
|
60
|
-
"eslint-config-airbnb-base": {
|
|
61
|
-
"json5": "^2.2.2"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"config": {
|
|
65
|
-
"commitizen": {
|
|
66
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
67
|
-
}
|
|
68
54
|
}
|
|
69
55
|
}
|