Basic Usage - dylanparry/ceylon GitHub Wiki
The easiest way to use Ceylon is to import it into your TypeScript or JavaScript project using the code below.
// In TypeScript or ES6
import expect from 'ceylon';
// In CommonJS
const expect = require('ceylon');
There is no need to download or reference a TypeScript definition file as the source code for Ceylon is all written in TypeScript, and definition files are included within the NPM package.
Add the following code to your HTML file:
<script src="https://unpkg.com/ceylon/lib/umd/ceylon.min.js"></script>
Ceylon is then exposed as window.expect
.
Here is a simple assertion that can be performed once you've referenced Ceylon:
expect(1 + 1).toBe(2);
expect(1 + 2).toBe(3); // Throws an AssertionError
See the full list of assertion types for more details on the different types of assertions that can be made.
All assertions can be chained, for example:
expect(100)
.toExist()
.toBeA('number')
.toBeLessThan(200)
.toBeGreaterThan(50)
.toNotBe(90);