Gathering detailed insights and metrics for @wemnyelezxnpm/impedit-ad-quibusdam
Gathering detailed insights and metrics for @wemnyelezxnpm/impedit-ad-quibusdam
Gathering detailed insights and metrics for @wemnyelezxnpm/impedit-ad-quibusdam
Gathering detailed insights and metrics for @wemnyelezxnpm/impedit-ad-quibusdam
npm install @wemnyelezxnpm/impedit-ad-quibusdam
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
12 Commits
1 Branches
Updated on Apr 27, 2024
Latest Version
1.0.0
Package Id
@wemnyelezxnpm/impedit-ad-quibusdam@1.0.0
Unpacked Size
22.64 kB
Size
8.14 kB
File Count
10
NPM Version
10.5.0
Node Version
20.12.2
Published on
Apr 26, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
33
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 @wemnyelezxnpm/impedit-ad-quibusdam
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 '@wemnyelezxnpm/impedit-ad-quibusdam'; 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/wemnyelezxnpm/impedit-ad-quibusdam/graphs/contributors
No vulnerabilities found.
No security vulnerabilities found.