Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

stakit-test-writer

kodedninja6ISC0.1.0

A small writer utility for testing stakit modules

stakit

readme

stakit-test-writer

A small writer utility for testing Stakit modules

Installation

npm i stakit-test-writer

Example

var tape = require('tape') // with tape-promise in reality
var stakit = require('stakit')
var testWriter = require('stakit-test-writer')

test('it works with stakit', async function (t) {
  t.plan(1)

  var kit = stakit()
    .routes(() => ['/'])
    .render((route, state) => `${route}`)

  var writer = testWriter()

  await kit.output(writer)

  t.ok(typeof writer.get('/index.html') === 'string', 'string was returned')
})

API

writer = testWriter()

Returns a new test writer instance.

writer.write

Stakit compatible write method.

writer.get(filepath)

Returns the mocked value of the "written" file at filepath.