@tramvai/test-unit 2.39.0 → 2.39.3
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 +0 -47
- package/lib/app/testApp.d.ts +1 -0
- package/lib/index.es.js +1 -0
- package/lib/index.js +1 -0
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -103,53 +103,6 @@ it('test', async () => {
|
|
|
103
103
|
</details>
|
|
104
104
|
</p>
|
|
105
105
|
|
|
106
|
-
### Testing app
|
|
107
|
-
|
|
108
|
-
> Testing app works only in node-environment. See [jest docs](https://jestjs.io/docs/27.0/configuration#testenvironment-string)
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
import { testApp } from '@tramvai/test-unit';
|
|
112
|
-
|
|
113
|
-
it('test', async () => {
|
|
114
|
-
const { request, render } = await testApp(app);
|
|
115
|
-
|
|
116
|
-
const response = await request('/').expect(200).expect('X-App-Id', 'unit-app');
|
|
117
|
-
|
|
118
|
-
expect(response.text).toMatch('<html class="no-js" lang="ru">');
|
|
119
|
-
expect(response.text).toMatch('<div class="application">rootPage</div>');
|
|
120
|
-
expect(response.text).toMatch('<script>var initialState =');
|
|
121
|
-
|
|
122
|
-
const rootPage = await render('/');
|
|
123
|
-
|
|
124
|
-
expect(rootPage.application).toEqual('rootPage');
|
|
125
|
-
|
|
126
|
-
const secondPage = await render('/second/');
|
|
127
|
-
|
|
128
|
-
expect(secondPage.application).toEqual('secondPage');
|
|
129
|
-
expect(secondPage.initialState).toEqual({
|
|
130
|
-
stores: expect.objectContaining({
|
|
131
|
-
environment: {
|
|
132
|
-
FRONT_LOG_API: 'test',
|
|
133
|
-
},
|
|
134
|
-
router: expect.objectContaining({
|
|
135
|
-
currentUrl: expect.objectContaining({
|
|
136
|
-
path: '\\u002Fsecond\\u002F',
|
|
137
|
-
}),
|
|
138
|
-
}),
|
|
139
|
-
}),
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
<p>
|
|
145
|
-
<details>
|
|
146
|
-
<summary>More examples</summary>
|
|
147
|
-
|
|
148
|
-
@inline src/app/testApp.spec.ts
|
|
149
|
-
|
|
150
|
-
</details>
|
|
151
|
-
</p>
|
|
152
|
-
|
|
153
106
|
### Adding providers to DI
|
|
154
107
|
|
|
155
108
|
Most of the helpers accepts option `providers` which allows to redefine already existing providers or add new.
|
package/lib/app/testApp.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { App } from '@tramvai/core';
|
|
|
3
3
|
/**
|
|
4
4
|
* Позволяет протестировать уже созданное через createApp приложение
|
|
5
5
|
* @param appOrAppPromise результат вызова createApp
|
|
6
|
+
* @deprecated используйте `startCli` метод из пакета `@tramvai/test-integration` для полноценного тестирования приложения
|
|
6
7
|
*/
|
|
7
8
|
export declare const testApp: (appOrAppPromise: App | Promise<App>) => Promise<{
|
|
8
9
|
app: App;
|
package/lib/index.es.js
CHANGED
|
@@ -130,6 +130,7 @@ const createTestApp = async ({ name = 'testApp', bundles = {}, providers = [], m
|
|
|
130
130
|
/**
|
|
131
131
|
* Позволяет протестировать уже созданное через createApp приложение
|
|
132
132
|
* @param appOrAppPromise результат вызова createApp
|
|
133
|
+
* @deprecated используйте `startCli` метод из пакета `@tramvai/test-integration` для полноценного тестирования приложения
|
|
133
134
|
*/
|
|
134
135
|
const testApp = async (appOrAppPromise) => {
|
|
135
136
|
const app = await appOrAppPromise;
|
package/lib/index.js
CHANGED
|
@@ -139,6 +139,7 @@ const createTestApp = async ({ name = 'testApp', bundles = {}, providers = [], m
|
|
|
139
139
|
/**
|
|
140
140
|
* Позволяет протестировать уже созданное через createApp приложение
|
|
141
141
|
* @param appOrAppPromise результат вызова createApp
|
|
142
|
+
* @deprecated используйте `startCli` метод из пакета `@tramvai/test-integration` для полноценного тестирования приложения
|
|
142
143
|
*/
|
|
143
144
|
const testApp = async (appOrAppPromise) => {
|
|
144
145
|
const app = await appOrAppPromise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/test-unit",
|
|
3
|
-
"version": "2.39.
|
|
3
|
+
"version": "2.39.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -18,21 +18,21 @@
|
|
|
18
18
|
"build-for-publish": "true"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tramvai/cli": "2.39.
|
|
22
|
-
"@tramvai/core": "2.39.
|
|
23
|
-
"@tramvai/module-common": "2.39.
|
|
24
|
-
"@tramvai/module-log": "2.39.
|
|
25
|
-
"@tramvai/module-metrics": "2.39.
|
|
26
|
-
"@tramvai/module-mocker": "2.39.
|
|
27
|
-
"@tramvai/module-render": "2.39.
|
|
28
|
-
"@tramvai/module-router": "2.39.
|
|
29
|
-
"@tramvai/module-server": "2.39.
|
|
30
|
-
"@tramvai/state": "2.39.
|
|
31
|
-
"@tramvai/test-helpers": "2.39.
|
|
32
|
-
"@tramvai/test-mocks": "2.39.
|
|
33
|
-
"@tramvai/tokens-common": "2.39.
|
|
34
|
-
"@tramvai/tokens-server": "2.39.
|
|
35
|
-
"@tramvai/tokens-server-private": "2.39.
|
|
21
|
+
"@tramvai/cli": "2.39.3",
|
|
22
|
+
"@tramvai/core": "2.39.3",
|
|
23
|
+
"@tramvai/module-common": "2.39.3",
|
|
24
|
+
"@tramvai/module-log": "2.39.3",
|
|
25
|
+
"@tramvai/module-metrics": "2.39.3",
|
|
26
|
+
"@tramvai/module-mocker": "2.39.3",
|
|
27
|
+
"@tramvai/module-render": "2.39.3",
|
|
28
|
+
"@tramvai/module-router": "2.39.3",
|
|
29
|
+
"@tramvai/module-server": "2.39.3",
|
|
30
|
+
"@tramvai/state": "2.39.3",
|
|
31
|
+
"@tramvai/test-helpers": "2.39.3",
|
|
32
|
+
"@tramvai/test-mocks": "2.39.3",
|
|
33
|
+
"@tramvai/tokens-common": "2.39.3",
|
|
34
|
+
"@tramvai/tokens-server": "2.39.3",
|
|
35
|
+
"@tramvai/tokens-server-private": "2.39.3",
|
|
36
36
|
"utility-types": "^3.10.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|