Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marionebl/ts-transformer-testing-library
Make testing custom TypeScript transformers a breeze
https://github.com/marionebl/ts-transformer-testing-library
Last synced: 9 days ago
JSON representation
Make testing custom TypeScript transformers a breeze
- Host: GitHub
- URL: https://github.com/marionebl/ts-transformer-testing-library
- Owner: marionebl
- License: mit
- Created: 2019-12-20T20:51:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:26:14.000Z (almost 2 years ago)
- Last Synced: 2024-10-18T12:25:24.183Z (18 days ago)
- Language: TypeScript
- Size: 946 KB
- Stars: 18
- Watchers: 3
- Forks: 4
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-typescript-ecosystem - ts-transformer-testing-library - Make testing custom TypeScript transformers a breeze (Transformers / Testing)
README
# ts-transformer-testing-libray
> Make testing custom TypeScript transformers a breeze
* :zap: Avoid tsc work
* :electric_plug: Work with multiple modules
* :surfer: Mock source modules as requiredCustom TypeScript transformers are a powerful way to
work with your source code, but coming up with a good
unit testing setup for them is hard.This library does the heavy lifting for you.
## Installation
```
yarn add -D ts-transformer-testing-library
```## Usage
```ts
// Transform a standalone TypeScript source
import { transform } from "ts-transformer-testing-library";const result = transform(`console.log('Hello, World!');`, {
transform() { /* Imaginary transform World ➞ You */ }
});console.log(result); // "Hello, You!";
``````ts
// Transform a standalone TypeScript source
import { transformFile } from "ts-transformer-testing-library";const result = transformFile({
path: '/index.ts',
contents: `import {phrase} from './phrase'; console.log(phrase);`
}, {
sources: [{ path: '/phrase.ts', contents: `export const phrase = 'Hello, World!'` }],
transform() { /* Imaginary transform World ➞ You */ }
});console.log(result); // "Hello, You!";
```## API
:warning: API is still in flux. Consult interfaces in source for details.
## License
MIT. Copyright 2019 - present Mario Nebl