intermock
Mocking library to create mock objects and JSON for TypeScript interfaces via Faker.
This is not an officially supported Google product.
Installation
npm install intermock
CLI
Intermock exposes a CLI, which is the recommended way to use the tool. The following subsections show an example file, command, and output to demonstrate using the CLI.
Example file
Example command
node ./node_modules/intermock/build/src/cli/index.js --files ./example-file.ts --interfaces "Admin"
Example output
API Usage
Intermock’s API exports only one function, as seen below:
Function
// Returns an object or string based on `output` property specified in `Options`mockoptions: Options: object|string
Options
Type Support
The following TypeScript features are supported:
- Interfaces
- Interfaces with properties of primitive types
- Interfaces with property references to other complex types
- Interfaces with extensions
- Unions
- Type aliases
- Arrays
- Namespaces
- Tuples
- Mapped types
- Generics
- Functions (stringified output!)
- Optional properties
- Specific Faker data types (via JSDoc comment)
Building
npm run build
Development
If you want to run the build script and tests after you save a file while developing,
run the following command:
npm run test-watch
Docs
Developing Docs
To develop documentation run the following commands:
npm run build
npm run docs-serve
Edit the files in docs/
and Webpack's Dev Server should auto-reload when there are changes
Statically Building Docs
To build the docs statically run the following command:
npm run build
npm run docs-build
Contributing
- Read all of
CONTRIBUTING.md
in this repo - Sign the CLA
- In a terminal, run
npm run ci
- Fix any linting, formatting, and/or compiling errors. (Note: Format errors can be fixed by
npm run format
. DO NOT fix linting errors by disabling the linter on a line and/or block) - Create a Pull Request
- Address all comments, if any
- If everything looks good after comments are addressed, your PR will be merged!
License
See LICENSE
in this repo