Skip to content

Commit e22adbb

Browse files
committed
chore: refactor error suppression tests to require in setup so hooks can actually be registered
1 parent 0337345 commit e22adbb

9 files changed

+36
-33
lines changed

src/dom/__tests__/errorSuppression.noAfterEach.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ describe('error output suppression (noAfterEach) tests', () => {
66
beforeAll(() => {
77
// @ts-expect-error Turning off AfterEach -- ignore Jest LifeCycle Type
88
afterEach = false
9+
require('..')
910
})
1011

11-
describe('first', () => {
12-
test('should not patch console.error', () => {
13-
require('..')
14-
expect(console.error).toBe(originalConsoleError)
15-
})
12+
test('should not patch console.error', () => {
13+
expect(console.error).toBe(originalConsoleError)
1614
})
1715
})
1816

src/dom/__tests__/errorSuppression.noBeforeEach.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ describe('error output suppression (noBeforeEach) tests', () => {
66
beforeAll(() => {
77
// @ts-expect-error Turning off BeforeEach -- ignore Jest LifeCycle Type
88
beforeEach = false
9+
require('..')
910
})
1011

11-
describe('first', () => {
12-
test('should not patch console.error', () => {
13-
require('..')
14-
expect(console.error).toBe(originalConsoleError)
15-
})
12+
test('should not patch console.error', () => {
13+
expect(console.error).toBe(originalConsoleError)
1614
})
1715
})
1816

src/dom/__tests__/errorSuppression.pure.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
// This verifies that if pure imports are used
2+
// then we DON'T auto-wire up the afterEach for folks
13
describe('error output suppression (pure) tests', () => {
24
const originalConsoleError = console.error
35

4-
test('should not patch console.error', () => {
6+
beforeAll(() => {
57
require('../pure')
8+
})
9+
10+
test('should not patch console.error', () => {
611
expect(console.error).toBe(originalConsoleError)
712
})
813
})

src/native/__tests__/errorSuppression.noAfterEach.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ describe('error output suppression (noAfterEach) tests', () => {
66
beforeAll(() => {
77
// @ts-expect-error Turning off AfterEach -- ignore Jest LifeCycle Type
88
afterEach = false
9+
require('..')
910
})
1011

11-
describe('first', () => {
12-
test('should not patch console.error', () => {
13-
require('..')
14-
expect(console.error).toBe(originalConsoleError)
15-
})
12+
test('should not patch console.error', () => {
13+
expect(console.error).toBe(originalConsoleError)
1614
})
1715
})
1816

src/native/__tests__/errorSuppression.noBeforeEach.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ describe('error output suppression (noBeforeEach) tests', () => {
66
beforeAll(() => {
77
// @ts-expect-error Turning off BeforeEach -- ignore Jest LifeCycle Type
88
beforeEach = false
9+
require('..')
910
})
1011

11-
describe('first', () => {
12-
test('should not patch console.error', () => {
13-
require('..')
14-
expect(console.error).toBe(originalConsoleError)
15-
})
12+
test('should not patch console.error', () => {
13+
expect(console.error).toBe(originalConsoleError)
1614
})
1715
})
1816

src/native/__tests__/errorSuppression.pure.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
// This verifies that if pure imports are used
2+
// then we DON'T auto-wire up the afterEach for folks
13
describe('error output suppression (pure) tests', () => {
24
const originalConsoleError = console.error
35

4-
test('should not patch console.error', () => {
6+
beforeAll(() => {
57
require('../pure')
8+
})
9+
10+
test('should not patch console.error', () => {
611
expect(console.error).toBe(originalConsoleError)
712
})
813
})

src/server/__tests__/errorSuppression.noAfterEach.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ describe('error output suppression (noAfterEach) tests', () => {
66
beforeAll(() => {
77
// @ts-expect-error Turning off AfterEach -- ignore Jest LifeCycle Type
88
afterEach = false
9+
require('..')
910
})
1011

11-
describe('first', () => {
12-
test('should not patch console.error', () => {
13-
require('..')
14-
expect(console.error).toBe(originalConsoleError)
15-
})
12+
test('should not patch console.error', () => {
13+
expect(console.error).toBe(originalConsoleError)
1614
})
1715
})
1816

src/server/__tests__/errorSuppression.noBeforeEach.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ describe('error output suppression (noBeforeEach) tests', () => {
66
beforeAll(() => {
77
// @ts-expect-error Turning off BeforeEach -- ignore Jest LifeCycle Type
88
beforeEach = false
9+
require('..')
910
})
1011

11-
describe('first', () => {
12-
test('should not patch console.error', () => {
13-
require('..')
14-
expect(console.error).toBe(originalConsoleError)
15-
})
12+
test('should not patch console.error', () => {
13+
expect(console.error).toBe(originalConsoleError)
1614
})
1715
})
1816

src/server/__tests__/errorSuppression.pure.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
// This verifies that if pure imports are used
2+
// then we DON'T auto-wire up the afterEach for folks
13
describe('error output suppression (pure) tests', () => {
24
const originalConsoleError = console.error
35

4-
test('should not patch console.error', () => {
6+
beforeAll(() => {
57
require('../pure')
8+
})
9+
10+
test('should not patch console.error', () => {
611
expect(console.error).toBe(originalConsoleError)
712
})
813
})

0 commit comments

Comments
 (0)