Gathering detailed insights and metrics for sassy-test
Gathering detailed insights and metrics for sassy-test
Gathering detailed insights and metrics for sassy-test
Gathering detailed insights and metrics for 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
npm install sassy-test
Typescript
Module System
Node Version
NPM Version
66.4
Supply Chain
99.3
Quality
75.5
Maintenance
100
Vulnerability
80.6
License
JavaScript (98.13%)
Makefile (1.87%)
Total Downloads
12,939
Last Day
2
Last Week
14
Last Month
87
Last Year
713
3 Stars
129 Commits
2 Forks
2 Watching
4 Branches
2 Contributors
Minified
Minified + Gzipped
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
Cumulative downloads
Total Downloads
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
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.
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.
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.
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
.
None but me yet. All are welcome! https://github.com/JohnAlbin/sassy-test/graphs/contributors
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
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 More