|
1 | 1 | # Ts Auto Mock |
2 | | -[](https://circleci.com/gh/uittorio/ts-auto-mock/tree/master) |
3 | | -[](https://greenkeeper.io/) |
| 2 | +[](https://circleci.com/gh/Typescript-TDD/ts-auto-mock) |
4 | 3 | [](https://badge.fury.io/js/ts-auto-mock) |
5 | 4 | [](https://www.npmjs.com/package/ts-auto-mock) |
6 | 5 |
|
7 | | - |
8 | 6 |  Need help? Join us on Slack [link](https://join.slack.com/t/typescripttdd/shared_invite/enQtODM3MzExODE0NTk2LTNmYzRhM2M1ZDc5ODVkMmVlZWFjMTM4ZDFhNWU2NDdiYWY1MGMxZjE2ZDE0ZDZlYjY1MTkyYjRhYTQ1NjA1MWQ) |
9 | 7 |
|
10 | 8 |
|
@@ -114,16 +112,42 @@ The library allows you to extends some functionality to work nicely with framewo |
114 | 112 | tsAutoMockTransformer(program: ts.Program, options: TsAutoMockOptions) |
115 | 113 |
|
116 | 114 | interface TsAutoMockOptions { |
117 | | - debug: boolean | 'file' | 'console' |
| 115 | + debug: boolean | 'file' | 'console'; |
| 116 | + cacheBetweenTests: boolean; |
118 | 117 | } |
119 | 118 | ``` |
120 | 119 | options: |
121 | 120 |
|
122 | | -| Name | Default | Description | |
123 | | -| ------------- | --------------------------- | --------------- | |
124 | | -| `debug` | `false` | When set to `true` or `console` it will log to the console |
125 | | -| | | When set to `file` it will log to a file (tsAutoMock.log) |
| 121 | +| Name | Default | Description | |
| 122 | +| ------------- | --------------------------- | --------------- | |
| 123 | +| `debug` | `false` | When set to `true` or `console` it will log to the console |
| 124 | +| | | When set to `file` it will log to a file (tsAutoMock.log) |
| 125 | +| `cacheBetweenTests` | `true` | When set to `true` it will reuse mocks between different tests |
| 126 | +| | | When set to `false` it create new mocks for each different tests |
| 127 | + |
| 128 | +#### Debug |
| 129 | +We currently support |
| 130 | +- Logs for [not supported types](docs/NOT_SUPPORTED.md) |
| 131 | +It will log any not supported type automatically converted to null. |
| 132 | +This is useful to report an issue or to investigate a potential bug |
| 133 | + |
| 134 | +#### cacheBetweenTests |
| 135 | +One of the main functionality of ts auto mock is to generate mocks and cache them. |
| 136 | + |
| 137 | +Mocks are currently created in the test file making tests to depend to each other |
| 138 | + |
| 139 | +Example: |
| 140 | +- test1.test.ts has a createMock of Interface. |
| 141 | +- test2.test.ts has a createMock of Interface. |
| 142 | +- test1.test.ts will have the registration of Interface mock |
| 143 | +- test2.test.ts will have a registration import. |
| 144 | + |
| 145 | +If test2 run in a different context than test1 it will not be able to access to the same mock. |
| 146 | + |
| 147 | +Set this property to false when your test run in different context. |
126 | 148 |
|
| 149 | +We are working on an [issue](https://github.com/Typescript-TDD/ts-auto-mock/issues/101) to make sure tests do not depend to each other but they will still take advance of a cache system |
| 150 | + |
127 | 151 | ## [Changelog](CHANGELOG.md) |
128 | 152 |
|
129 | 153 | ## Authors |
|
0 commit comments