Tape Planner Promise

Related tags

Testing washi-tape
Overview

washi-tape

Washi Tape makes a test planner from a Tape instance that makes it easy to plan and await parts of your tests.

npm install washi-tape

Usage

const net = require('net')
const tape = require('tape')
const plan = require('washi-tape')

tape('some test', async function (t) {
  // make a new test instance that requires 3 asserts
  const serverTest = plan(t, 3)

  // do something async and call the required assertions
  const server = net.createServer(function (socket) {
    serverTest.pass('got socket')
    socket.once('data', function (data) {
      serverTest.ok(data instanceof Buffer)
      socket.end()
    })
  })

  server.listen(10000, () => {
    const s = net.connect(10000)
    s.end('hello world', function () {
      serverTest.pass('client socket finished')
    })
  })

  // wait for the server assertions to finish
  await serverTest

  // two assertions afterwards
  const serverClose = plan(t, 2)

  server.on('close', function () {
    serverClose.pass('server emitted close')
  })
  server.close(function () {
    serverClose.pass('can pass event handler to close itself')
  })

  // wait for the final assertions
  await serverClose
})

API

p = plan(t, count)

Make a plan instance promise that waits count asserts before resolving.

p inherits all its assertion methods from tape so you can call p.same, p.deepEqual etc.

Once count assertions have been called the promise will resolve.

p.same(...), p.pass(...) etc

The promise returned extends the tape assertion object so you can run all your normal assertions on it.

await p

Resolves when count assertions have run.

p.timeoutAfter(ms)

Similar to t.timeoutAfter but also rejects the promise.

License

MIT

You might also like...

Promise based HTTP client for the browser and node.js

axios Promise based HTTP client for the browser and node.js New axios docs website: click here Table of Contents Features Browser Support Installing E

Jan 3, 2023

A promise library for JavaScript

If a function cannot return a value or throw an exception without blocking, it can return a promise instead. A promise is an object that represents th

Dec 30, 2022

:bird: :zap: Bluebird is a full featured promise library with unmatched performance.

Got a question? Join us on stackoverflow, the mailing list or chat on IRC Introduction Bluebird is a fully featured promise library with focus on inno

Jan 5, 2023

Promise based HTTP client for the browser and node.js

axios Promise based HTTP client for the browser and node.js New axios docs website: click here Table of Contents Features Browser Support Installing E

Dec 31, 2022

:bird: :zap: Bluebird is a full featured promise library with unmatched performance.

Got a question? Join us on stackoverflow, the mailing list or chat on IRC Introduction Bluebird is a fully featured promise library with focus on inno

Dec 31, 2022

Delay a promise a specified amount of time

delay Delay a promise a specified amount of time If you target Node.js 15 or later, you can do await require('timers/promises').setTimeout(1000) inste

Dec 26, 2022

Promise ponyfill with pinkie

pinkie-promise ES2015 Promise ponyfill Module exports global Promise object (if available) or pinkie Promise polyfill. Install $ npm install --save pi

Jan 16, 2022

Memoize promise-returning functions. Includes cache expire and prefetch.

promise-memoize Memoize promise-returning functions. Includes cache expire and prefetch. When data expire mode enabled, new values are fetched in adva

Nov 1, 2022

A Promise-based API for WebSockets

A Promise-based API for WebSockets

websocket-as-promised A WebSocket client library with Promise-based API for browser and Node.js. Example import WebSocketAsPromised from 'websocket-as

Dec 18, 2022

Slide-element - A ~700 byte Promise-based library for animating elements with dynamic heights open & closed. Basically, a modern variant of jQuery's slideUp(), slideDown(), and slideToggle().

slide-element A tiny, accessible, Promise-based, jQuery-reminiscent library for sliding elements with dynamic heights open & closed. To see it in acti

Dec 12, 2022

Init a target by promise only once.

once-init đź—Ľ Let Promise Function Executed Only Once. The Promise will be executed when the attribute target is called for the first time, and the Pro

Dec 26, 2022

Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill).

@sanity/client Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill). Requirements Sanity Clien

Nov 29, 2022

Debounce promise-returning & async functions.

perfect-debounce An improved debounce function with Promise support. Well tested debounce implementation Native Promise support Avoid duplicate calls

Jan 2, 2023

Converts an iterable, iterable of Promises, or async iterable into a Promise of an Array.

iterate-all A utility function that converts any of these: IterableT IterablePromiseT AsyncIterableT AsyncIterablePromiseT Into this: Prom

Jun 7, 2022

Promise-based utility to control modal states in React

Promise-based utility to control modal states in React

Promise-based utility to control modal states in React Zero-dependency library that easily integrates with your existing UI components and allows you

Dec 5, 2022

A simple Node.js package that helps you not to look up JavaScript promise syntax every time you use it.

A simple Node.js package that helps you not to look up JavaScript promise syntax every time you use it.

A simple Node.js package that helps you not to look up JavaScript promise syntax every time you use it. Simple: Provides abstraction of the promise sy

Oct 8, 2022

Promise based HTTP client for the browser and node.js

axios Promise based HTTP client for the browser and node.js New axios docs website: click here Table of Contents Features Browser Support Installing E

Jan 5, 2023

Base provides advanced Promise Queue Manager, Custom Console Logger and other utilities.

Base Base provides frequently used functionality like cutome logger, response helper, Custom Promise and Instance composer. These are used in almost a

Jun 14, 2022

Plug-and-play, faster-than-native promise/callback event emitter

Plug-and-play, faster-than-native promise/callback event emitter

kNow Blazing-fast callback/promise-based events with a tiny footprint What is this? With kNow (pronounced "now"—the k's silent), JavaScript event mana

Sep 11, 2022
Owner
Mathias Buus
Rød grød med fløde
Mathias Buus
Tape Planner Promise

washi-tape Washi Tape makes a test planner from a Tape instance that makes it easy to plan and await parts of your tests. npm install washi-tape Usag

Mathias Buus 17 Sep 7, 2021
Inside-out promise; lets you call resolve and reject from outside the Promise constructor function.

Inside-out promise; lets you call resolve and reject from outside the Promise constructor function.

Lily Scott 3 Feb 28, 2022
Test runner based on Tape and Browserify

prova Node & Browser Test runner based on Tape and Browserify. Screencasts: node.gif, browser.gif, both.gif, headless browser Slides: slides.com/azer/

Azer Koçulu 335 Oct 28, 2022
Real-time motion planner and autonomous vehicle simulator in the browser, built with WebGL and Three.js.

Dash Self-Driving Car Simulator Real-time motion planner and autonomous vehicle simulator in the browser, built with WebGL and Three.js. This project

Matt Bradley 209 Dec 3, 2022
Recipe providing mobile app, User selects ingredients in pantry and is then provided recipes for those ingredients. App contains a signup/login, meal planner and grocery list pages.

Recipog Student Information Name Connor de Bruyn Username Destiro Assignment SWEN325 A2 Description “Recipog” is a recipe providing app that allows th

Connor de Bruyn 1 Dec 26, 2021
This is a YouTube Video Planner app built with NextJS, GraphQL, Prisma and MongoDB for the MongoDB Atlas Hackathon

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Justin Chau 2 Jan 14, 2022
Three.js-based room configurator (floor planner + product configurator)

Three.js-based room configurator (floor planner + product configurator) Live Features 1. FloorPlan Design Users can edit floorplan in 2d view mode. Th

Pegasus 55 Dec 28, 2022
Planning a getaway with family or friends and looking for a trip planner app to help you figure out the logistics?

Never-Wavering-Wayfaring-Wanderlust-Adventure-Planner Planning a getaway with family or friends and looking for a trip planner app to help you figure

Michelle Blackwell 3 Jun 15, 2022
Kitchen planner companion to the game PlateUp!

PlateUp! Planner Plan your PlateUp! kitchen before you jump into the game. We are not officially affiliated with PlateUp! or its creators. No copyrigh

null 15 Dec 17, 2022
a roadtrip planner web application.

Rally - Roadtrip Planner Rally Map is a comprehensive web application that helps you plan your dream road trip with ease. With Rally Map, you can crea

Panapat Pilapa 4 Mar 20, 2023