Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
literate-jasmine
Advanced tools
write tests in markdown that are parsed to specification files to run with jasmine-node
var PI;
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 a markdown structure (which includes the main header above and the other parts below) that is parsed into a tree:
Which is then written to disk as FILENAME_spec.js
. Take a look at README_spec.js
as an example -- it is generated using this README as input!
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
.
Take a close look at how scope works for globals. In the Mathematics section below, we
reference PI
to reset it as a beforeEach
so every test has PI
reset to the correct
value. The actual declaration of PI
as a variable happens on the fourth line of this
README. The root describe treats any code blocks after it as global setup.
PI = 22/7;
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);
Note that we reference the variable PI below that is defined in the code block at the top of this describe (so right under "Mathematics").
var circumference = function(radius) {
return 2 * PI * radius;
};
expect(circumference(5)).toBe(2 * 22/7 * 5);
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.