Coder Social home page Coder Social logo

chai-latte's Introduction

chai-latte

This library wraps the Chai assertion library, so it can be used from ClojureScript in a convenient way.

Familiarity with the Chai library itself is assume. Refer to the Chai guide for an introduction.

[chai-latte "0.2.0"]

Read the Changelog for a list of changes in the current version.

Installation

When running on NodeJS, simply install Chai via npm.

npm install chai

Browser Support

When testing front end code in a browser or in a headless setup, you need to provide a browser build of chai.js and any plugins to Chai that you may be using, which are usually included via a script tag.

This library will try to autodetect if the environment is a browser or nodejs.

Examples

To write an assertion construct a form of the following shape:

(ns mylib.test.core
 (require [latte.chai :refer (expect)]))
...
(expect <actual> <test-expression> <expectation>)

valid forms would be:

(expect 1 :to.equal 1)
(expect 1 :not.to.equal 2)

Test expressions are always keywords of dot delimited fragments. All of the Chai chainable language constructs are available. See Chai's expect API as a reference.

All values after the test expression are passed as parameters to the test method given by the test expression. If the test epxression points to a property instead of a method, no parameters are allowed.

(epxect true :to.be.ok)

State of the Implementation

Currently only the expect API of Chai is wrapped.

Differences From Chai

Whenever required the wrapper extends the Chai chainable language pieces to deal with Clojure values. As an example the following is a passing assertion:

(expect {:a 1 :b 2} :to.equal {:a 1 :b 2})

because Chai is extended to respect Clojure's concept of equality when dealing with complex data structures.

Due to an implementation detail in Chai it is currently not possible to properly support the following assertion.

(expect [1 2 3] :to.incude 1)

While using this library, an additional method is present in Chai, which can be used in the following way.

(expect [1 2 3] :to.include.value 1)

chai-latte's People

Contributors

jkrueger avatar

Stargazers

salotz avatar Emilien avatar Alexander R Scott avatar Josef Pospíšil avatar Andrea Richiardi avatar Dany Haddad avatar  avatar Honza Břečka avatar Jorge David avatar Ravi Kotecha avatar Joaquin avatar

Watchers

Benjamin Teuber avatar  avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.