@mixin assert()
Description
Define a CSS-output assertion. Assertions are used inside the test()
mixin to define the expected results of the test.
- The
assert()
mixin is a wrapper, and should contain oneoutput()
block and oneexpect()
block as nested contents. - These three mixins together describe a single
assert-equal
comparison on output CSS. The compiled CSS-results of theoutput()
mixin will be compared against the results of theexpect()
mixin. - When using Mocha integration, the output comparison is automated โ otherwise you will have to compare the output manually. Using
git diff
is a great way to watch for changes in output.
Parameters
$description: null (string)
Description of the assertion being tested. A null
of false
value generates a default description.
@content (code block)
Use `output()` and `expect()` mixins to define blocks for comparison
Example
@include test('Sass math compiles before output') {
@include assert('You can also describe the assertion...') {
@include output {
width: 14em + 2;
}
@include expect {
width: 16em;
}
}
}
/* Test: Sass math compiles before output */
/* ASSERT: You can also describe the assertion... */
/* OUTPUT */
.test-output {
width: 16em;
}
/* END_OUTPUT */
/* EXPECTED */
.test-output {
width: 16em;
}
/* END_EXPECTED */
/* END_ASSERT */
/* */
requires
@mixin _true-output-context() [private]
@mixin _true-context() [private]
@mixin _true-message() [private]
@mixin _true-update-test() [private]
@mixin _true-update-stats-count() [private]
@mixin _true-context-pop() [private]
@function _true-context() [private]
@mixin output()
Description
Describe the test content to be evaluated against the paired expect()
block. Assertions are used inside the test()
mixin to define the expected results of the test.
- The
output()
mixin requires a content block, and should be nested inside theassert()
mixin along with a singleexpect()
block. - These three mixins together describe a single
assert-equal
comparison on output CSS. The compiled CSS-results of theoutput()
mixin will be compared against the results of theexpect()
mixin. - When using Mocha integration, the output comparison is automated โ otherwise you will have to compare the output manually. Using
git diff
is a great way to watch for changes in output.
Parameters
$selector: true (bool)
Optionally wrap the contents in a .test-output
selector block, so you can test property-value output directly.
@content (code block)
Define the test content to be checked
Example
@include test('Sass math compiles before output') {
@include assert {
@include output {
width: 14em + 2;
}
@include expect {
width: 16em;
}
}
}
/* Test: Sass math compiles before output */
/* ASSERT: */
/* OUTPUT */
.test-output {
width: 16em;
}
/* END_OUTPUT */
/* EXPECTED */
.test-output {
width: 16em;
}
/* END_EXPECTED */
/* END_ASSERT */
/* */
@mixin expect()
Description
Describe the expected results of the paired output()
block. The expect()
mixin requires a content block, and should be nested inside the assert()
mixin, along with a single output()
block. Assertions are used inside the test()
mixin to define the expected results of the test.
- These three mixins together describe a single
assert-equal
comparison on output CSS. The compiled CSS-results of theoutput()
mixin will be compared against the results of theexpect()
mixin. - When using Mocha integration, the output comparison is automated โ otherwise you will have to compare the output manually. Using
git diff
is a great way to watch for changes in output.
Parameters
$selector: true (bool)
Optionally wrap the contents in a .test-output
selector block, so you can test property-value output directly.
@content (code block)
Define the expected results of a sibling `output()` mixin
Example
@include test('Sass math compiles before output') {
@include assert {
@include output {
width: 14em + 2;
}
@include expect {
width: 16em;
}
}
}
/* Test: Sass math compiles before output */
/* ASSERT: */
/* OUTPUT */
.test-output {
width: 16em;
}
/* END_OUTPUT */
/* EXPECTED */
.test-output {
width: 16em;
}
/* END_EXPECTED */
/* END_ASSERT */
/* */