Node.js built-in assertion library for testing. Provides various assertion methods to validate test expectations. Throws AssertionError when assertions fail, causing the test to fail.

import { assert } from './worker/uds';

// Basic equality assertions
assert.equal(actual, expected);
assert.strictEqual(actual, expected);
assert.notEqual(actual, unexpected);

// Boolean assertions
assert.ok(value); // truthy check
assert.equal(value, true);

// Array and object assertions
assert.deepEqual(actualObject, expectedObject);
assert.deepStrictEqual(actualArray, expectedArray);

// Error assertions
assert.throws(() => {
throw new Error('Expected error');
});

// CAN message validation example
test('should validate CAN message structure', () => {
const canMsg = { id: 0x123, data: [0x01, 0x02] };
assert.ok(canMsg.id);
assert.equal(typeof canMsg.id, 'number');
assert.ok(Array.isArray(canMsg.data));
assert.equal(canMsg.data.length, 2);
});

// UDS response validation example
test('should validate UDS positive response', () => {
const response = [0x50, 0x01]; // Positive response to service 0x10
assert.equal(response.length, 2);
assert.equal(response[0], 0x50);
assert.equal(response[1], 0x01);
});

Namespaces

strict

Classes

AssertionError
CallTracker

Interfaces

CallTrackerCall
CallTrackerReportInformation

Type Aliases

AssertPredicate

Functions

deepEqual
deepStrictEqual
doesNotMatch
doesNotReject
doesNotThrow
equal
fail
ifError
match
notDeepEqual
notDeepStrictEqual
notEqual
notStrictEqual
ok
rejects
strict
strictEqual
throws