best-behavior v0.15.2
best-behavior
Best-Behavior is a domain-specific language and command line tool for writing executable documentation and validating that your software conforms to it. It utilizes Vite and Playwright to allow you to write tests that exercise your Javascript code in Node or a real web browser with no config necessary.
Getting Started
Best-Behavior works best with Typescript.
Best-Behavior uses Vite and Playwright. These are all peer dependencies of best-behavior; install them explicitly to control their versions.
In addition, best-behavior requires a matcher library. We recommend installing great-expectations for this purpose.
$ npm install --save-dev best-behavior great-expectations vite playwright
Writing a Behavior
Let's write a simple behavior.
import { behavior, example, effect } from "best-behavior"
import { expect, is, stringContaining } from "great-expectations"
export default behavior("My first behavior", [
example()
.description("My first example")
.script({
observe: [
effect("it works", () => {
expect("funny", is(stringContaining("fun")))
})
]
})
])
Each of your test files should be structured like the example here, with a default
export of a Behavior
.
Validating the Behavior
To validate this behavior, use the best
cli and provide a glob that
matches the file. So suppose you save the file as ./behaviors/fun.behavior.ts
, you
could run the file, like so:
$ best --behaviors './behaviors/**/*.behavior.ts'
Learn More!
4 months ago
5 months ago
5 months ago
6 months ago
6 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago