@tramvai/test-integration 1.46.6 → 1.46.7
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 +13 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Tramvai test integration
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Set of helpers to simplify the process of writing integration tests for the tramvai app. Implies full-fledged run of the app with build made by `@tramvai/cli` and use of helpers for test result of requests to the server and test render of the app in the browser.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> The `@tramvai/cli` package is required and should be installed manually
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm i --save-dev @tramvai/test-integration
|
|
@@ -12,13 +12,13 @@ npm i --save-dev @tramvai/test-integration
|
|
|
12
12
|
|
|
13
13
|
## How To
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Test request to the tramvai app without using browser (aka `curl`)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
For testing requests to the tramvai app libraries [superagent](https://github.com/visionmedia/superagent) and [node-html-parser](https://github.com/taoqf/node-html-parser) are used under hood.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Call of `app.request` sends requests to the app. All of the features of `superagent` are available.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Call of `app.render` resolves to the HTML render that is returned from server while serving the request.
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
import { startCli } from '@tramvai/test-integration';
|
|
@@ -36,7 +36,7 @@ afterAll(() => {
|
|
|
36
36
|
return app.close();
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
it('request to main page return status 200', async () => {
|
|
39
|
+
it('request to main page should return status 200', async () => {
|
|
40
40
|
return app.request('/').expect(200);
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -48,15 +48,15 @@ it('main page HTML snapshot', async () => {
|
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
###
|
|
51
|
+
### Testing app in browser with the `puppeteer`
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
You may use another library [@tramvai/test-puppeteer](references/test/test-puppeteer.md) to implement testing in the browser.
|
|
54
54
|
|
|
55
|
-
###
|
|
55
|
+
### Usage of `@tinkoff/mocker` in tests
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
In order to use mocker there should be added [`@tramvai/module-mocker`](references/modules/mocker.md) to the tramvai app modules list.
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
After thar mocker will read file based mocks as it described in the docs to the mocker itself and it can be used dynamically in the tests:
|
|
60
60
|
|
|
61
61
|
```ts
|
|
62
62
|
it('should work with mocker', async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/test-integration",
|
|
3
|
-
"version": "1.46.
|
|
3
|
+
"version": "1.46.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@tinkoff/mocker": "1.5.3",
|
|
25
|
-
"@tramvai/test-helpers": "1.46.
|
|
25
|
+
"@tramvai/test-helpers": "1.46.7",
|
|
26
26
|
"@types/supertest": "^2.0.11",
|
|
27
27
|
"supertest": "^6.1.3",
|
|
28
28
|
"utility-types": "^3.10.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@tinkoff/utils": "^2.1.2",
|
|
33
|
-
"@tramvai/cli": "1.46.
|
|
33
|
+
"@tramvai/cli": "1.46.7",
|
|
34
34
|
"tslib": "^2.0.3"
|
|
35
35
|
},
|
|
36
36
|
"license": "Apache-2.0",
|