@magic/test
Error Codes Quick Look
Quick reference for @magic/test error codes. Import from `@magic/test`:
import { ERRORS, createError } from '@magic/test'Error Codes Reference Table
| Code | Description | Example Usage || :--- | :---------- | :------------ || ERRORS.E_EMPTY_SUITE | Test suite is not exporting any tests | createError(ERRORS.E_EMPTY_SUITE, "Empty test suite") || ERRORS.E_RUN_SUITE_UNKNOWN | Unknown error occurred while running a suite | createError(ERRORS.E_RUN_SUITE_UNKNOWN, "Unexpected execution error") || ERRORS.E_TEST_NO_FN | Test object is missing the `fn` property | createError(ERRORS.E_TEST_NO_FN, "Missing test function") || ERRORS.E_TEST_EXPECT | Test expectation failed | createError(ERRORS.E_TEST_EXPECT, "Expected value does not match") || ERRORS.E_TEST_BEFORE | Before hook failed | createError(ERRORS.E_TEST_BEFORE, "Setup hook threw error") || ERRORS.E_TEST_AFTER | After hook failed | createError(ERRORS.E_TEST_AFTER, "Cleanup hook threw error") || ERRORS.E_TEST_FN | Test function threw an error | createError(ERRORS.E_TEST_FN, "Test function crashed") || ERRORS.E_NO_TESTS | No test suites found | createError(ERRORS.E_NO_TESTS, "No test files discovered") || ERRORS.E_IMPORT | Failed to import a test file | createError(ERRORS.E_IMPORT, "Cannot resolve test file path") || ERRORS.E_MAGIC_TEST | General test execution error | createError(ERRORS.E_MAGIC_TEST, "Internal test runner error") |
Usage Example
Create custom errors with specific codes and messages:
import { createError, ERRORS } from '@magic/test'export default [{fn: () => createError(ERRORS.E_TEST_NO_FN, 'Missing fn property'),expect: e => e.code === 'E_TEST_NO_FN' && e.message === 'Missing fn property',info: 'createError creates errors with code and message',},]
Error Object Properties
- code - The error code string (e.g., "E_TEST_NO_FN")
- message - Human-readable error message
- stack - Stack trace for debugging
See also:
Full Error Codes Reference