current-time-website
Version:
For testing, a website that displays the current time (rounded)
57 lines (40 loc) • 1.17 kB
Markdown
[![NPM version][npm-image]][npm-url]
For testing certain kinds of software, a website that displays the
current time, arbitrary rounded.
```terminal
$ npm i -g current-time-website
...
$ current-time-website &
$ opn http://localhost:3000
```
Example running at <https://time.hawkeworks.com/>.
Can also do a cycle. Click on this link, then keep refreshing it. It
should change its response every 3 seconds:
* <https://time.hawkeworks.com/?units=3&cycle=red;orange;yellow;green;blue;violet>.
```js
const { create } = require('current-time-website')
...
test(async (t) => {
const site = await create({
port: 0,
offset: Date.now() / 1000,
units: 0.1,
cycle: ['a', 'b', 'c']
})
let data
data = await (await fetch(site.siteurl)).text()
t.equal(data, 'a')
await delay(100)
data = await (await fetch(site.siteurl)).text()
t.equal(data, 'b')
await site.stop()
t.end()
})
```
[]: https://img.shields.io/npm/v/current-time-website.svg?style=flat-square
[]: https://npmjs.org/package/current-time-website