OddBird stands with the Black community in demanding change. Make a donation, and OddBird will match it.


Open Source

True: Sass Unit Testing

Write your tests in Sass, and report with Mocha

True is a full-featured unit-testing library for Sass. The core functionality is written in pure SassScript, so it can be used anywhere Sass is compiled. Advanced features are available with our test-runner integration and Mocha.

For Sass developers, by Sass developers

‘npm package’ ‘build status’

We designed True as one of the first testing frameworks for the Sass language, in order to provide tests for Susy, our Sass layout toolkit. Since then, True has become the only full-featured unit-testing software that allows you to write and compile your tests with plain Sass mixins.

Write your tests in Sass, compile them with Sass, and then (optionally) pass the results to a Javascript test-runner for command-line control and reporting.

Getting Started

Install the sass-true module using yarn or npm:

yarn add sass-true --dev
npm install sass-true --save-dev

Then import the library, along with the code you are testing in Sass:

@import "<path/to/node_modules>/sass-true/sass/true";

Define tests in Sass with a BDD (describe/it) or TDD (test-module/test) syntax:

@include describe('multiply() function') {
  @include it('Returns the result of multiplication') {
    // …

@include test-module('multiply() function') {
  @include test('Returns the result of multiplication') {
    // …

Compare internal Sass values (variables and functions) by asserting is-equal, is-unequal, is-true, or is-false:

// Testing Functions
@include assert-equal(
  multiply(12, 2),

Test CSS output (mixins) with the assert, output, and expect mixins:

// Testing Mixins
@include assert {
  @include output {
    @include font-size('large');

  @include expect {
    font-size: 2rem;
    line-height: 3rem;

Optionally show a summary report in the CSS output and/or the command line:

@include report;

Or use our Javascript integration to run and report tests directly in the command line. Read the docs for more!

We’re here for you

Ask us anything. We want to answer your questions, and get to know you – your needs, goals, and expertise – so we can provide thoughtful advice, and help guide you to a successful launch of your web project.

Schedule a call with Miriam