Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@clubedaentrega/test-spec
Advanced tools
A parser and runtime for markdown-inspired documentation and testing files
A parser and runtime for markdown-inspired documentation and testing files
npm install @clubedaentrega/test-spec --save
var spec = require('@clubedaentrega/test-spec')
// Usually, the source is read from some *.md file
var source = '# Title\n'+
'## Sub section\n'+
'Some textual content\n'+
'\tuser:\n'+
'\t\tname: "Gui".toUpperCase()'
// Compile the source to a tree of section, text and value blocks
var mainSection = spec.compile(source),
subSection = mainSection.children[0],
valueBlock = subSection.children[1],
// Execute the value block
value = valueBlock.run()
console.log(value) // {user: {name: 'GUI'}}
Testing is, at the same time:
This module tries to solve this by making testing code more concise and unifying testing and documentation.
Markdown was choosen because it's easy to write/read and it's not code!
This module is the fundamental parser and compiler for api-test, but can be used separately.
This module implements a tiny subset of markdown: headers, paragraphs and code blocks. It does not aim at understanding any other feature (like lists, images, links, etc), but those constructions are accepted. That is, they are not considered valid syntax, but are simply treated as text.
The source is first transformed into a tree of sections (headers). Each section may have sub-sections, text paragraphs and value blocks.
Parsed values are compiled to native JS functions, exposing a run()
method, like in example above.
The syntax for value expressions was designed to be concise and expressive. The values will be eval'ed as normal JS with a context with special variables (see default context
bellow).
The object can be a simple JS value, like:
new Date
Or an object with one property by line and tabs used to declare sub-objects:
user:
name:
first: 'Happy'
last: 'Customer'
age: 37 + 2
country: 'cm'.toUpperCase()
Or mixins, like:
user with name.first: 'Unhappy'
Learn more about the syntax in the file value-syntax.md
The following functions are defined in spec.baseContext
and can be used to provide a common set of utility functions to tests.
randomStr([len=8], [alphabet=a-zA-Z0-9+/])
randomHex([len=8])
randomCode([len=8])
randomEmail([domain='example.com'])
randomUrl([base='http://example.com'])
random([min=0],[max=1])
randomInt([min=0],[max=100])
randomBool()
randomDate([interval=1day], [base=now])
: return a random date in the pastrandomOf(...values)
: return one of its argumentsempty
: the empty object {}
See complete docs
FAQs
A parser and runtime for markdown-inspired documentation and testing files
The npm package @clubedaentrega/test-spec receives a total of 2 weekly downloads. As such, @clubedaentrega/test-spec popularity was classified as not popular.
We found that @clubedaentrega/test-spec 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.