• Run cleanup code after each test in the current suite. MUST be used within a describe block. Only executes if the corresponding test is enabled through testEnableControl. Used for cleaning up resources, closing connections, or resetting state after each test.

    Parameters

    • fn: () => void | Promise<void>

      Function to run after each test (can be sync or async)

    Returns void

    describe('UDS Diagnostic Tests', () => {
    // ✅ Correct: afterEach inside describe block
    afterEach(async () => {
    await can.close();
    });

    afterEach(() => {
    uds.setTesterPresent(false);
    uds.clearDtc();
    testData = null;
    });

    test('should perform diagnostics', () => {
    // Test implementation
    });
    });

    // ❌ Wrong: afterEach outside describe block
    // afterEach(() => { // This will not work properly });