Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
literate-jasmine
Advanced tools
write tests in markdown that are parsed to specification files to run with jasmine-node
The idea is to write markdown that gets translated to Jasmine describe
and
it
blocks. Because we want to be able to annotate in between parts of what
would become a single it
, we make use of markdown hierarchy to separate one
test from another and to give the it
(and describe
blocks names).
This README.md has this markdown structure (which includes the main header above and the other parts below):
# literate-jasmine
## Mathematices
### add can add numbers (level 3 header)
### add can add numbers
## Strings
### appending works with +
Which is parsed into a tree:
literate-jasmine
Mathematices
add can add numbers (level 3 header)
add can add numbers
Strings
appending works with +
Which is then written to disk as FILENAME_spec.js
(so README_spec.js
):
describe('literate-jasmine', function() {
describe('Mathematics', function() {
it('add can add numbers', function() {
// test code
});
it('can divide numbers', function() {
// test code
});
});
describe('Strings', function() {
it('appending works with +', function() {
// test code
});
});
});
The command literate-jasmine
is used to convert the markdown to JavaScript
(assuming you ran npm install -g literate-jasmine
):
literate-jasmine README.md
(If you're working on this project, run ./bin/literate-jasmine
instead.)
Then run the jasmine tests:
> jasmine-node README_spec.js
1 2 3
....
Finished in 0.006 seconds
4 tests, 4 assertions, 0 failures, 0 skipped
var a = 1,
b = 2;
console.log(a, b, a + b);
expect(a + b).toBe(3);
var a = 6,
b = 2;
And a comment here doesn't break things:
expect(a/b).toBe(3);
var text = "abc";
expect(text + "d").toBe("abcd");
FAQs
Write jasmine tests in markdown as documentation
The npm package literate-jasmine receives a total of 1 weekly downloads. As such, literate-jasmine popularity was classified as not popular.
We found that literate-jasmine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.