Installations
npm install sassy-test
Developer Guide
Typescript
No
Module System
ESM
Node Version
20.9.0
NPM Version
10.1.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (98.13%)
Makefile (1.87%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
12,939
Last Day
2
Last Week
14
Last Month
87
Last Year
713
GitHub Statistics
3 Stars
129 Commits
2 Forks
2 Watching
4 Branches
2 Contributors
Bundle Size
2.97 MB
Minified
661.45 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.0.1
Package Id
sassy-test@5.0.1
Unpacked Size
56.97 kB
Size
18.68 kB
File Count
5
NPM Version
10.1.0
Node Version
20.9.0
Publised On
10 Nov 2023
Total Downloads
Cumulative downloads
Total Downloads
12,939
Last day
-87.5%
2
Compared to previous day
Last week
-60%
14
Compared to previous week
Last month
155.9%
87
Compared to previous month
Last year
-35.9%
713
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Sassy Test
Sassy Test is a simple helper utility for creating unit tests of Sass modules.
Sassy Test models its testing after the unit tests in LibSass. The tests are a series of sub-folders in the "test/fixtures" directory that contain an "input" Sass file and an "output" CSS file. Its unit tests then reference a particular folder, compile 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
│ └─┬ my-modules-warn/
│ ├── input.scss
│ └── output.css
└── test_mymodule.scss
Then in our test file, test/test_mymodule.js, we can use sassyTest
to simplify our tests:
1import path from 'node:path'; 2import { expect } from 'chai'; 3import SassyTest from 'sassy-test'; 4 5const sassyTest = new SassyTest({ 6 // Path to the Sass module we are testing and its dependencies. 7 loadPaths: [ 8 path.join(__dirname, '../sass'), 9 path.join(__dirname, '../node_modules/breakpoint-sass/stylesheets') 10 ] 11 // Since our fixtures are in test/fixtures, we don't need to override 12 // the default value by setting the "fixtures" path here. 13 // fixtures: path.join(__dirname, 'fixtures'), 14}); 15 16describe('@import "mymodule";', function() { 17 describe('@function my-modules-function()', function() { 18 it('should test an aspect of this function', async function() { 19 // Sassy Test's compileFixture() will run a comparison test between the 20 // compiled input.scss and the output.css found in the fixtures 21 // sub-directory specified in its first parameter, in this case: 22 // test/fixtures/my-modules-function 23 return sassyTest.compileFixture('my-modules-function') 24 .catch(error => { 25 // If we expect the comparison test to succeed, we just need to test 26 // that no error occurred. 27 expect(error).to.not.exist; 28 }) 29 .then(result => { 30 // No additional assertions are needed, but we can run other tests 31 // here if we desire. 32 }); 33 }); 34 35 it('should throw an error in this situation', async function() { 36 // Sassy Test's compileFixture() can also test if your module produces an 37 // intentional error with Sass' @error directive. 38 return sassyTest.compileFixture('my-modules-error') 39 .catch(error => { 40 // If the Sass in test/fixtures/my-modules-error/input.scss triggers an 41 // @error in your module, you should expect the error object to exist 42 // and to contain the error message from your module. 43 expect(error).to.exist; 44 expect(error.message).to.equal('Some helpful error message from your module.'); 45 }); 46 }); 47 48 it('should warn in another situation', async function() { 49 // Sassy Test's compileFixture() can also test if your module produces an 50 // intentional warning message with Sass' @warn directive. 51 return sassyTest.compileFixture('my-modules-warn') 52 .catch(error => { 53 // If the Sass in test/fixtures/my-modules-warn/input.scss triggers a 54 // @warn in your module, you should expect the result object to exist 55 // and to contain the warn message from your module. 56 expect(error).to.not.exist; 57 }) 58 .then(result => { 59 // Sassy Test adds two new arrays to sass' result object: 60 // result.warn and result.debug are arrays of strings. 61 expect(result.warn[0]).to.equal('Some helpful warning from your module.'); 62 }); 63 }); 64 }); 65});
For more information about configuring a SassyTest object, see the configurePaths()
method documentation.
JavaScript Promises
SassyTest's compile()
, compileString()
and compileFixture()
methods return a Promise
.
1describe('@import "mymodule";', function() { 2 describe('@function my-modules-function()', function() { 3 it('should test an aspect of this function', function() { 4 // Mocha accepts sassyTest's returned Promise. 5 return sassyTest.compileFixture('my-modules-function'); 6 }); 7 8 it('should throw an error in this situation', function() { 9 return sassyTest.compileFixture('my-modules-error').then(function(result) { 10 // If the expected Sass error does not occur, we need to fail the test. 11 expect(result).to.not.exist('An error should have occurred'); 12 }).catch(function(error) { 13 expect(error).to.exist; 14 expect(error.message).to.include('Some helpful error message from your module.'); 15 }); 16 }); 17 18 it('should warn in another situation', function() { 19 return sassyTest.compileFixture('my-modules-warn').then(function(result) { 20 expect(result.warn[0]).to.equal('Some helpful warning from your module.'); 21 }); 22 }); 23 }); 24});
Full documentation of Sassy Test’s JavaScript API is available online.
Development
Forking, hacking, and tearing apart of this software is welcome! It's still very simple and could use additional features and conveniences.
After you've cloned this repository, run npm install
and then you'll be able to run the module's mocha and eslint tests with npm test
.
Contributors
None but me yet. All are welcome! https://github.com/JohnAlbin/sassy-test/graphs/contributors
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
- Info: topLevel 'contents' permission set to 'read': .github/workflows/static.yml:14
- Info: no jobLevel write permissions found
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/static.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/JohnAlbin/sassy-test/static.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/static.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/JohnAlbin/sassy-test/static.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/static.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/JohnAlbin/sassy-test/static.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/static.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/JohnAlbin/sassy-test/static.yml/main?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 3 are checked with a SAST tool
Score
4.3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to sassy-test
test-package-deactivation-test-chore-sassy-beers-ruths
empty
test-package-deactivation-test-sassy-hewed-slosh-bield
empty
@malware-test-avens-sassy-globy-paths/test-mlw3-avens-sassy-globy-paths
security holding package
test-mlw4-sassy-dunce-dance-route
empty