Gathering detailed insights and metrics for @ugate/labrat
Gathering detailed insights and metrics for @ugate/labrat
Gathering detailed insights and metrics for @ugate/labrat
Gathering detailed insights and metrics for @ugate/labrat
npm install @ugate/labrat
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
32 Commits
1 Watchers
12 Branches
1 Contributors
Updated on Dec 29, 2020
Latest Version
2.1.0
Package Id
@ugate/labrat@2.1.0
Unpacked Size
14.49 kB
Size
4.77 kB
File Count
4
NPM Version
6.13.4
Node Version
12.14.1
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
3
🐁 Run @hapi/lab tests on vanilla test suites
npm install -D @ugate/labrat
test/lib/tester.js:
1// vanilla test suite (all tests should be static) 2 3const { Labrat, LOGGER } = require('@ugate/labrat'); 4 5class Tester { 6 7 static async before() { 8 // OPTIONAL: run before all tests 9 } 10 11 static async after() { 12 // OPTIONAL: run after all tests 13 } 14 15 static async beforeEach() { 16 // OPTIONAL: run before each test 17 } 18 19 static async afterEach() { 20 // OPTIONAL: run after each test 21 } 22 23 static myTest1() { 24 if (LOGGER.info) LOGGER.info('Show this when info level enabled'); 25 // test here 26 } 27 28 static async myTest2() { 29 Labrat.header('My Test #2'); 30 // test here 31 } 32 33 static async testException() { 34 // do something that throws an error 35 throw new Error('TEST Error'); 36 } 37} 38 39// when not ran in a test runner execute static Tester static functions 40if (!Labrat.usingTestRunner()) { 41 (async () => await Labrat.run(Tester))(); 42}
test/tester.js:
1const Lab = require('@hapi/lab'); 2const Tester = require('./lib/tester'); 3const lab = Lab.script(); 4exports.lab = lab; 5 6const plan = `Demo`; 7 8lab.experiment(plan, () => { 9 10 if (Tester.before) lab.before(Tester.before); 11 if (Tester.after) lab.after(Tester.after); 12 if (Tester.beforeEach) lab.beforeEach(Tester.beforeEach); 13 if (Tester.afterEach) lab.afterEach(Tester.afterEach); 14 15 lab.test(`${plan}: Test #1`, { timeout: 1000 }, Tester.myTest1); 16 lab.test(`${plan}: Test #2`, { timeout: 1000 }, Tester.myTest2); 17 lab.test(`${plan}: Test Error`, { timeout: 1000 }, 18 Labrat.expectFailure('onUnhandledRejection', { expect, label: 'throw error' }, Tester.testException) 19 ); 20});
-NODE_ENV=development
or -NODE_ENV=dev
- All levels/functions included in console-NODE_ENV=test
- Includes console.info, console.warn, console.error-NODE_ENV=production
or -NODE_ENV=prod
- Includes console.warn, console.errorTests can be ran in a Node.js
command or in @hapi/lab.
Run in node:
node test/lib/tester.js -NODE_ENV=test
Run myTest1 in node:
node test/lib/tester.js -NODE_ENV=test myTest1
Run in @hapi/lab:
"node_modules/.bin/lab" test/tester.js -v
Run myTest1 in @hapi/lab:
"node_modules/.bin/lab" test/tester.js -vi 1
Run myTest2 in @hapi/lab:
"node_modules/.bin/lab" test/tester.js -vi 2
Logs a message with header formatting
Convenience function that will handle expected thrown errors
type
(String | Array<String>) The flags
type/name that will be set on incoming flags (e.g. onUnhandledRejection
, onUncaughtException
, etc.)opts
Object The failure options
func
Function A test function with a signature of async function(flags)
that @hapi/lab
acceptsAsync test that will either resolve
/reject
after a given amount of time
delay
Integer The delay in milliseconds to wait before resolving/rejectingval
any? The value to return when resolved or error message/Error when rejectingrejectIt
Boolean? true
to reject, otherwise resolveReturns Boolean true
when the process is being ran from a test utility
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
47 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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