Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cancerberosgx/resource-mocker
API and CLI to mock a static resources like .js, .css, .html files in a local server
https://github.com/cancerberosgx/resource-mocker
Last synced: about 1 month ago
JSON representation
API and CLI to mock a static resources like .js, .css, .html files in a local server
- Host: GitHub
- URL: https://github.com/cancerberosgx/resource-mocker
- Owner: cancerberoSgx
- License: mit
- Created: 2018-09-05T13:25:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-05T22:34:08.000Z (over 6 years ago)
- Last Synced: 2024-10-31T10:52:23.688Z (about 2 months ago)
- Language: JavaScript
- Size: 52.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
API and CLI sto mock a static resources like .js, .css, .html files in a local server. It creates a real http local server that serves provided resources.
# Usage
```sh
npm install --save-dev resource-mocker
``````js
import { ServerMocker } from 'resource-mocker'
import { get } from 'hyperquest-promise'const resources = [
{ name: '/file1.js', content: 'window.file1 = "file1"' },
{
name: '/file1.html', content: `hello world1
`
},
]
const mocker = new ServerMocker({ port: 3000, resources })
mocker.start()let { data } = await get('http://localhost:3000/file1.html')
expect(data).toContain('hello world1')
mocker.shutdown()
```# TODO
* read config from .json file
* CLI (so I can entre `resource-mocker --config test-assets/resources1.json` --port 3000)
* suggestion: build .json of resources in folder (using my program fs-to-json)-->
-->-->
-->
-->
-->