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 assertionsassert.equal(actual, expected);assert.strictEqual(actual, expected);assert.notEqual(actual, unexpected);// Boolean assertionsassert.ok(value); // truthy checkassert.equal(value, true);// Array and object assertionsassert.deepEqual(actualObject, expectedObject);assert.deepStrictEqual(actualArray, expectedArray);// Error assertionsassert.throws(() => { throw new Error('Expected error');});// CAN message validation exampletest('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 exampletest('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);}); Copy
import { assert } from './worker/uds';// Basic equality assertionsassert.equal(actual, expected);assert.strictEqual(actual, expected);assert.notEqual(actual, unexpected);// Boolean assertionsassert.ok(value); // truthy checkassert.equal(value, true);// Array and object assertionsassert.deepEqual(actualObject, expectedObject);assert.deepStrictEqual(actualArray, expectedArray);// Error assertionsassert.throws(() => { throw new Error('Expected error');});// CAN message validation exampletest('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 exampletest('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);});
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.
Example