Installations
npm install example-runner
Developer Guide
Typescript
No
Module System
CommonJS
NPM Version
1.4.23
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
square
Download Statistics
Total Downloads
180,723
Last Day
9
Last Week
33
Last Month
125
Last Year
2,423
GitHub Statistics
1 Stars
12 Commits
12 Watchers
2 Branches
1 Contributors
Updated on Jan 28, 2023
Package Meta Information
Latest Version
0.2.0
Package Id
example-runner@0.2.0
Size
4.08 kB
NPM Version
1.4.23
Published on
Aug 27, 2014
Total Downloads
Cumulative downloads
Total Downloads
180,723
Last Day
350%
9
Compared to previous day
Last Week
22.2%
33
Compared to previous week
Last Month
54.3%
125
Compared to previous month
Last Year
-84.8%
2,423
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
example-runner
Run example files with assertions. example-runner can be used as a very basic test runner, optionally with a source transform function. This makes it suitable for testing JavaScript-to-JavaScript compilers such as es6-class, where it is used.
Install
$ npm install [--save-dev] example-runner
Usage
example-runner has two exported functions: run
and runCLI
. Most of the time
you'll probably want to use runCLI
which prints to stdout and exits with the
appropriate status code. If you need to customize the output or exit behavior
of example-runner, such as to fit it into another tool, you can use run
.
runCLI(files, options)
With no arguments, runCLI
will run test/examples/*.js
.
1require('example-runner').runCLI();
You can run specific files if you want:
1require('example-runner').runCLI(['a.js', 'b.js']);
Provide the transform
option if you want to modify your examples before
running, such as with sweet.js:
1require('example-runner').runCLI({
2 transform: function(source, testName, filename, options) {
3 return sweetjs.compile(source);
4 }
5});
The arguments given to transform
are:
- source: A string with the source of the example file.
- testName: The base name of the example file, sans
.js
suffix. - filename: The path to the example file.
- options: Options parsed from comments in the source of the example file.
This is useful if how you transform the source is different per file and you
need a way to configure it. For example,
/* config a:b, log:true */
in the source file will create options like so:{ config: { a: "b", log: true } }
.
If you need to pass data to your example files, use the context
option.
1require('example-runner').runCLI({ 2 context: { mydata: [1, 2], mylib: require('mylib') } 3});
Note that there are some default context properties:
- assert: This is the node assert library. At least one assertion must be
made for an example file to be considered successful. You can disable this
behavior by adding
/* example-runner assert:false */
at the top of your example file. - __options: This is the same options object passed to
transform
(see above).
run(files, options)
Like runCLI()
, run()
takes files and options. Unlike runCLI()
it returns
an EventEmitter
that emits three events:
pass(testName)
: called when an example file passesfail(testName, error)
: called when an example file fails, along with the error throwndone(passed, failed)
: called when all tests have run, along with the names of the passed and failed examples

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2025-02-17
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