Socket
Socket
Sign inDemoInstall

sassy-test

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sassy-test - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

LICENSE.txt

2

gh-pages/api-homepage.md

@@ -1,2 +0,2 @@

# sassy-test API<br><small>version: `master` branch</small>
# sassy-test API<br><small>version: `1.0.1`</small>

@@ -3,0 +3,0 @@ This is the JavaScript API documentation for the sassy-test software. [The code

@@ -47,7 +47,10 @@ 'use strict';

configurePaths: function(config) {
// Don't override the default value if none is provided.
// Don't override the default values or previously-set values, if no new
// values are provided.
if (config.fixtures) {
this.paths.fixtures = config.fixtures;
}
this.paths.library = config.library || '';
if (config.library) {
this.paths.library = config.library;
}
},

@@ -67,5 +70,5 @@

* var fixturePath = sassyTest.fixture();
* // Returns full path to fixtures/sub-folder.
* // Returns full path to [fixtures]/sub-folder.
* var fixturePath = sassyTest.fixture('sub-folder');
* // Returns full path to fixtures/sub-folder/_file.scss.
* // Returns full path to [fixtures]/sub-folder/_file.scss.
* var fixturePath = sassyTest.fixture('sub-folder', '_file.scss');

@@ -91,4 +94,4 @@ * ```

* - converts render.css from a buffer to a string
* - converts render.map to an object (if you configured the proper sourcemap
* options)
* - converts render.map to an object (Note: you will need to configure the
* proper sourcemap options)
*

@@ -213,3 +216,5 @@ * ```

// Give the callback access to the results.
if (results.outputError) {
if (results.outputError && !results.sassError) {
// Ensure the callback notices the output error by removing the sass
// result.
callback(results.outputError, null, null);

@@ -216,0 +221,0 @@ } else {

{
"name": "sassy-test",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/JohnAlbin/sassy-test",

@@ -5,0 +5,0 @@ "author": "John Albin Wilkins <virtually.johnalbin@gmail.com> (http://john.albin.net/)",

[![Build Status](https://secure.travis-ci.org/JohnAlbin/sassy-test.png?branch=master)](http://travis-ci.org/JohnAlbin/sassy-test) [![Coverage Status](https://coveralls.io/repos/JohnAlbin/sassy-test/badge.svg?branch=master&service=github)](https://coveralls.io/github/JohnAlbin/sassy-test?branch=master)
# sassy-test
# Sassy Test
Sassy Test is a simple helper utility for creating unit tests of Sass modules. Works great with mocha or jasmine.
Sassy Test is a simple helper utility for creating unit tests of Sass modules.
Install for your Sass module with: `npm install --save-dev sassy-test`
Sassy Test models its testing after the unit tests in LibSass. LibSass has a series of sub-folders in its "test/fixtures" directory that contain an "input" Sass file and an "output" CSS file. Its unit tests then reference a particular folder, render the input.scss and compare the results to the output.css file.
To get started, just install Sassy Test as a development dependency of your Sass module with: `npm install --save-dev sassy-test`
Sassy Test will work with any Node.js test runner, like mocha or jasmine.
## A quick demo of Mocha + Sassy Test
Example project's root directory:
```
| # You can put your module's Sass files anywhere.
| # We use "sass" as an example.
├─┬ sass/
│ └── _mymodule.scss
│ # Mocha prefers your tests to live in a "test" folder.
│ # Sassy Test will automatically find your fixtures if
│ # they are in /test/fixtures, but you can change the
│ # path with configurePaths().
└─┬ test/
├─┬ fixtures/
│ │ # Test fixtures can be deeply nested.
│ ├─┬ my-modules-function/
│ │ ├── input.scss
│ │ └── output.css
│ └─┬ my-modules-error/
│ ├── input.scss
│ └── output.css
├── helper.js
└── test_mymodule.scss
```
With mocha, we can place a call to `before()` in the root of any test file and it will be run once before all the other tests in every `test_*.js` file. We can also `require()` files and assign them to the `global` object to make them available to all `test_*.js` files. A file called helper.js can be used to set up our mocha global requires and `before()`:
```JavaScript
'use strict';
// Globals for all test_*.js files.
global.path = require('path');
global.should = require('chai').should();
global.sassyTest = require('sassy-test');
// This before() is run before any test_*.js file.
before(function(done) {
sassyTest.configurePaths({
// Path to the Sass module we are testing.
library: path.join(__dirname, '../sass')
// Since our fixtures are in test/fixtures, we don't need to override
// the default value by setting the "fixtures" path here.
});
done();
});
```
For more information, see the [`configurePaths()` documentation](http://johnalbin.github.io/sassy-test/module-sassy-test.html#.configurePaths).
Then in our test file, test_mymodule.js, we can use `sassyTest` to simplify our tests:
```JavaScript
'use strict';
describe('@import "mymodule";', function() {
describe('@function my-modules-function()', function() {
it('should test an aspect of this function', function(done) {
// Sassy Test's renderFixture() will run a comparison test between the
// rendered input.scss and the output.css found in the fixtures
// sub-directory specified in its first parameter, in this case:
// test/fixtures/my-modules-function
sassyTest.renderFixture('my-modules-function', {}, function(error, result, expectedOutput) {
// If we expect the comparison test to succeed, we just need to test
// that no error occurred and then done(), but we can run other tests
// here if we desire; both expectedOutput (the contents of output.css)
// and node-sass's result object are available.
if (error) throw error;
done();
});
});
it('should throw an error in this situation', function(done) {
// Sassy Test's renderFixture() can also test if your module produces an
// intentional error with Sass' @error directive.
sassyTest.renderFixture('my-modules-error', {}, function(error, result, expectedOutput) {
// If the Sass in test/fixtures/my-modules-error/input.scss triggers an
// @error in your module, you should expect the error object to exist
// and to contain the error message from your module.
error.should.exist;
error.message.should.equal('Some helpful error message from your module.');
done();
});
});
});
});
```
[Full documentation of Sassy Test’s JavaScript API](http://johnalbin.github.io/sassy-test) is available online.
## Development

@@ -11,0 +104,0 @@

@@ -57,2 +57,11 @@ 'use strict';

it('should not reset to the default value a previously set library path', function(done) {
sassyTest.configurePaths({
library: 'c/path'
});
sassyTest.configurePaths({});
sassyTest.paths.library.should.equal('c/path');
done();
});
after(function(done) {

@@ -230,2 +239,3 @@ // Reset the paths for the rest of the tests.

error.message.should.be.string;
error.message.should.equal('renderFixture failure.');
error.should.have.property('column');

@@ -243,2 +253,13 @@ error.column.should.be.number;

it('should ignore the output error and return the node-sass error', function(done) {
sassyTest.renderFixture('renderFixture/failureNoOutput', {}, function(error, result, expectedOutput) {
should.not.exist(result);
should.not.exist(expectedOutput);
error.should.be.error;
error.message.should.equal('renderFixture failure, not an output error.');
error.should.not.have.property('code');
done();
});
});
it('should read the output.css file of the given fixtures directory', function(done) {

@@ -245,0 +266,0 @@ sassyTest.renderFixture('renderFixture/success', {}, function(error, result, expectedOutput) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc