@amazon/vinyl-mock-generator 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. package/README.md +44 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @amazon/vinyl-mock-generator
2
+
3
+ [![Website](https://img.shields.io/badge/website-amazonmusic.github.io%2Fvinyl-blue)](https://amazonmusic.github.io/vinyl)
4
+ [![npm](https://img.shields.io/npm/v/@amazon/vinyl-mock-generator.svg)](https://www.npmjs.com/package/@amazon/vinyl-mock-generator)
5
+
6
+ A TypeScript-driven mock class generator. Reads a library's `.d.ts` files
7
+ through the TypeScript compiler API and emits a `Mock<Name>` implementation for
8
+ every interface, with sensible default property values and customizable spy
9
+ methods. Used to keep test doubles in sync with library types as they evolve.
10
+
11
+ ## Install
12
+
13
+ ```shell
14
+ npm install --save-dev @amazon/vinyl-mock-generator
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Build a script that calls `generateMocks` with the library's entry points and
20
+ your spy convention. The result is a single file you check in next to your
21
+ tests:
22
+
23
+ ```typescript
24
+ import { generateMocks } from '@amazon/vinyl-mock-generator'
25
+
26
+ generateMocks({
27
+ library: '@amazon/vinyl',
28
+ rootNames: ['index.d.ts'],
29
+ outFile: './test/generated/mocks.ts',
30
+ header: `import { spy } from './spyHelper'\n\n`,
31
+ createSpyMethod: (_iface, method) =>
32
+ ` ${method.name} = spy('${method.name}')`,
33
+ })
34
+ ```
35
+
36
+ `interfaceFilter` can narrow which interfaces are emitted, and
37
+ `initializeMockClass` lets you inject extra constructor logic.
38
+
39
+ See the player docs at
40
+ [amazonmusic.github.io/vinyl](https://amazonmusic.github.io/vinyl).
41
+
42
+ ## License
43
+
44
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amazon/vinyl-mock-generator",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Generates mock classes from interfaces",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,5 +34,5 @@
34
34
  }
35
35
  },
36
36
  "typesVersions": {},
37
- "gitHead": "ea13070fb52c1903723f08f31c356465d2f3279e"
37
+ "gitHead": "e5a3429d802564132b16808a5b8a8e15a023a548"
38
38
  }