Skip to content

Commit

Permalink
test: add stackTrace test and improve test descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrocheleau committed Feb 21, 2022
1 parent fd78bb9 commit e359bff
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions packages/util/test/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ErrorLogger } from '../src/errors'
tape('ErrorLogger', (t) => {
const errorLog = new ErrorLogger()

t.test('should assign the UNKNOWN_ERROR code to errors with undefined code', (st) => {
t.test('should assign the UNKNOWN_ERROR code to errors without code', (st) => {
let error: any

try {
Expand All @@ -16,6 +16,18 @@ tape('ErrorLogger', (t) => {
st.equal(error.code, ErrorLogger.errors.UNKNOWN_ERROR)
st.end()
}),
t.test('should preserve the stack trace of the throwError context', (st) => {
let error: any

try {
errorLog.throwError()
} catch (e) {
error = e
}

st.ok(/Error: {2}\| Details: code=UNKNOWN_ERROR\n {4}at Test./.test(error.stack))
st.end()
}),
t.test('should populate an error with UNKNOWN_ERROR code with all provided params', (st) => {
let error: any

Expand All @@ -28,26 +40,12 @@ tape('ErrorLogger', (t) => {
error = e
}

st.equal(error.code, ErrorLogger.errors.UNKNOWN_ERROR)
st.equal(error.errorInfo1, 'Information on the error')
st.equal(error.errorInfo2, 'More information on the error')
st.end()
})
t.test('should populate an error with UNKNOWN_ERROR code with all provided params', (st) => {
let error: any

try {
errorLog.throwError(ErrorLogger.errors.UNKNOWN_ERROR, {
errorInfo1: 'Information on the error',
errorInfo2: 'More information on the error',
})
} catch (e) {
error = e
}

st.equal(error.code, ErrorLogger.errors.UNKNOWN_ERROR)
st.end()
}),
t.test('should add all error params to error message details', (st) => {
}),
t.test('should add all error params of UNKNOWN_ERROR to error message details', (st) => {
let error: any

try {
Expand All @@ -65,7 +63,7 @@ tape('ErrorLogger', (t) => {
)
st.end()
}),
t.test('should append all error params to existing error message', (st) => {
t.test('should append all error details to provided error message', (st) => {
let error: any

try {
Expand Down

1 comment on commit e359bff

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: e359bff Previous: f4f34c8 Ratio
Block 9422910 8504 ops/sec (±21.75%) 19995 ops/sec (±2.06%) 2.35

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.