Skip to main content

New stuff: Gists, WaitFor, Testing

Marius Andra

Marius Andra

Kea Core Team

Few more things got released all at once:

Funny Gists#

I added a playground page with three interesting code snippets for Kea:

They are all too rough to be released as official plugins yet, but can already help in some situations.

If you have the time, feel free to contribute new gists or improve on the existing ones!


The kea-waitfor plugin lets you await for actions.

It's great if you're writing tests and want to wait for something to happen before leaving the test

import { kea } from 'kea'
import { waitForAction } from 'kea-waitfor'
const logic = kea({
actions: () => ({
setValue: value => ({ value }),
valueWasSet: value => ({ value })
listeners: ({ actions }) => ({
setValue: async ({ value }) => {
await delay(300)
const { value } = await waitForAction(logic.actions.valueWasSet)
// --> 'hamburger'

There's also a waitForCondition that lets you ask custom questions from the dispatched actions.

const { value } = await waitForCondition(action => {
return action.type === logic.actions.valueWasSet.toString() &&
action.payload.value === 'cheeseburger'

In addition, the plugin documentation includes examples for waiting for different cominations of actions:

  • Wait for all to be dispatched
  • Wait for the first one of many (race)
  • Timeout on the waiting

Testing docs#

Inspired by a Github Issue, I wrote a quick doc about unit testing kea logic. Feedback and contributions are very welcome!

Kea is growing.

Stay in the loop and get the latest updates via email.