![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Status: API finalized, needs testing
deadunit
A dead-simple nesting unit testing module for node.js (and someday the browser!). This repository provides default visual representations for the output of deadunit-core, as well as a formatter that can be used to easily create custom test visualizations.
'Now with both console and HTML output!'
ok
and count
) making it easy to learn.count
method elegantly solves various issues like expecting exceptions and asynchronous asserts - just count
up the number of ok
s!this.done()
).Deadunit doesn't work in the browser yet tho, whereas Jasmine and Tree do.
var Unit = require('deadunit')
var test = Unit.test('some test name', function() {
this.count(5) // expect all 5 `ok` assertions
var obj = someFunctionToTest()
this.ok(obj.x === 5)
this.ok(obj.y === 'y')
this.test('nested test', function() {
this.ok(obj.go() > 4)
})
try {
doSomethingBad()
} catch(e) {
this.ok(true) // expect an exception
}
doSomethingAsynchronous(function(result) {
this.ok(result === 'good')
})
})
test.writeConsole() // writes colorful output!
test.html() // returns pretty html!
npm install deadunit
var Unit = require('deadunit')
Unit.test([<name>, ]<testFunction>)
- runs a suite of unit tests. Returns an ExtendedUnitTest object.
Unit.error(<handler>)
- see deadunit-core
Unit.format(<unitTest>, <format>)
- creates custom formatted output for test results according to the passed in <format>
.
Unit.string(<results>, <colorize>)
- returns a string containing formatted test results for the passed in. The format of the results is the format returned by deadunit-core's results
method. See below for screenshots.
<unitTest>
is a UnitTest
(or ExtendedUnitTest
) object<format>
- an object containing functions that format the various types of results. Each formater function should return a String
.
format.assert(result, testName)
result
is a deadunit-core assert result objecttestName
is the name of the test the assert is underformat.exception(exception)
exception
is an exception object (could be any object that was thrown)format.group(name, totalDuration, totalSynchronousDuration, testCaseSuccesses, testCaseFailures,
assertSuccesses, assertFailures, exceptions, results, exceptionResults, nestingLevel)
name
is the test group nametotalDuration
- the total duration the test took from start to the last test-actiontotalSynchronousDuration
- the time it took for the test function to complete synchronously (ignores all asynchronous parts)testCaseSuccesses
- the number of successful asserts (the ok
method) and groups in this test group. Does not count asserts and test-groups inside subtest groupstestCaseFailures
- the number of failed asserts and groups in this test group. Does not count asserts and test-groups inside subtest groupsassertSuccesses
- the number of successful asserts in this test group and all subgroups.assertFailures
- the number of failed asserts in this test group and all subgroups.exceptions
- the number of exceptions in this test group and all subgroups.results
- an array of already-formatted test results.exceptionResults
- an array of already-formatted exceptions.nestingLevel
is what level of test group this is. The top-level test is at level 0.format.log(values)
values
is an array of logged valuesFor documentation on how to write unit tests, see deadunit-core.
This object extends UnitTest from deadunit-core. Also has the following methods:
test.string(<colorize>)
- returns a future that resolves to a string containing formatted test results. See below for screenshots.
test.writeConsole(<hangingTimeout>)
- writes colorized text output to the console. Returns a future that resolves when the console writing is complete. <hangingTimeout>
is optional (default 100), and if non-zero, a warning will be displayed if the script doesn't exit before <hangingTimeout>
number of milliseconds has passed. If zero, no warning happens. See below for screenshots.
test.html()
- returns a string containing html-formatted test results. See below for screenshots.
test.results()
- see deadunit-core
Passing tests are closed and failling tests are open by default. Clicking on the bars toggles sections open or closed.
Javascript (and node.js especially) has a lot of asynchronous parts. Deadunit allows your tests to run asychronously/concurrently, but you have to manage that concurrency.
I recommend that you use either:
fibers/future
s,colors
supports a safe mode (where it doesn't modify the String prototype), use that. Modifying builtins is dangerous.Anything helps:
How to submit pull requests:
npm install
at its roottest.writeConsole
prints out the testtest.results
test.writeConsole
and test.html
only return when the test is done (or times out)test.writeConsole
outputs test results as they happen in addition to outputting the final outputtest.toString
test.string
and test.html
now return futuresReleased under the MIT license: http://opensource.org/licenses/MIT
FAQs
A dead-simple nestable unit testing library for javascript and node.js.
The npm package deadunit receives a total of 29 weekly downloads. As such, deadunit popularity was classified as not popular.
We found that deadunit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.