This is a fluent assertions plugin for the Alsatian xUnit framework, for JavaScript and TypeScript. It provides a way to chain assertions while narrowing the scope, enabling the clear and concise expression of code specifications for those who prefer a fluent style. By contrast, the default expectations framework in Alsatian is not currently fluent.
Assert(obj)
.is(UserModel)
.has(o => o.name)
.that.hasMatch(/\d+/) // alt 'matches' that returns match result scope
.that.converted(parts => +parts[0])
.equals(7);
Assert(obj).equals(expected);
Assert(obj)
.hasAsserts({ // same as .has/.hasProperties with MatchMode.Asserts
name: "agent 007",
address: a => a.is(Redacted),
phone: /\+44\d{10}/,
deploy: a => a.is(Function).not.throws()
});
Please visit our wiki.
If you already have Alsatian installed, just save this with your devDependencies.
npm i -sD alsatian-fluent-assertions