Project: syntax-tree/nlcst-test

Package: nlcst-test@3.1.0

  1. Dependents: 0
  2. nlcst utility to check assert an nlcst node
  1. util 143
  2. utility 139
  3. unist 127
  4. nlcst 14
  5. check 11
  6. nlcst-util 9
  7. test 6
  8. assert 4


Build Coverage Downloads Size Sponsors Backers Chat

nlcst utility to assert trees.


This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.


npm install nlcst-test


import {assert} from 'nlcst-test'

assert({type: 'RootNode', children: []})
assert({type: 'SourceNode', value: 'fn()'})
assert({type: 'WordNode', children: [{type: 'TextNode', value: 'Hi'}]})
// All OK.

assert({children: []})
// AssertionError: node should have a type: `{ children: [] }`

assert({type: 'WordNode', value: 'foo'})
// AssertionError: parent should have children: `{ type: 'WordNode', value: 'foo' }`


This package exports the following identifiers: assert, parent, literal, _void, and wrap. There is no default export.


Assert that tree is a valid nlcst node. If tree is a parent, all children will be asserted as well.

The other methods come from unist-util-assert.


See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer