https://github.com/jwill9999/static-server-for-running-tests
Nodejs http server to serve static files when running tests.
https://github.com/jwill9999/static-server-for-running-tests
api-documentation api-wrapper fs html http http-server nodejs path static-server testing-tools
Last synced: about 1 month ago
JSON representation
Nodejs http server to serve static files when running tests.
- Host: GitHub
- URL: https://github.com/jwill9999/static-server-for-running-tests
- Owner: jwill9999
- Created: 2018-09-21T23:48:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-23T18:48:51.000Z (over 7 years ago)
- Last Synced: 2025-06-24T13:11:03.590Z (12 months ago)
- Topics: api-documentation, api-wrapper, fs, html, http, http-server, nodejs, path, static-server, testing-tools
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Testing Server
## Description
If your running tests that require a server to serve static files, such as when using "Puppeteer" it often requires a degree of configuration. Testing Server provides an easy API to start and stop your server programatically. The server is configured to serve a number of static file types as illustrated below. If your serving an HTML file then this needs to be placed within a src folder.
Alternatively you can run your server from the command line.
```
######## CLI ###############
node index.js 3000
```
```
######### FILE PATH & PORT ############
> HTML File served from 'src' folder
> Default port 8080
```
### MIMETYPES AVAILABLE
> ico : image/x-icon
> html : text/html
> js : text/javascript
> json : application/json
> css : text/css
> png : image/png
> jpg : image/jpeg
> wav : 'audio/wav
> mp3 : audio/mpeg
> svg : image/svg+xml
> pdf : application/pdf
> doc : application/msword
> eot : appliaction/vnd.ms-fontobject
> ttf : aplication/font-sfnt
## API
```
init() > starts server port 8080
close() > terminates running server
```
## API Example
```
############### Example ######################
const server = require('path_to_serverFile')
server.init()
server.close()
```