Skip to content

Commit

Permalink
Merge pull request #1170 from serlo/jest-improvements
Browse files Browse the repository at this point in the history
test: Small improvements
  • Loading branch information
kulla authored Dec 1, 2023
2 parents d5533a8 + 2bb2971 commit c3f125e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions __config__/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jest.mock('@google-cloud/storage', () => {
}
})

beforeAll(async () => {
await createBeforeAll({
beforeAll(() => {
createBeforeAll({
onUnhandledRequest(req) {
if (
req.method === 'POST' &&
Expand Down
4 changes: 3 additions & 1 deletion __config__/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { flush as flushSentry } from '@sentry/node'
import crypto from 'crypto'
import { http, HttpResponse } from 'msw'
import { SetupServer, setupServer } from 'msw/node'
Expand Down Expand Up @@ -61,7 +62,7 @@ export async function createBeforeEach() {
givenSpreadheetApi(defaultSpreadsheetApi())

global.server.use(
http.post('https://127.0.0.1/api/0/envelope', async ({ request }) => {
http.post('https://127.0.0.1/api/0/envelope/', async ({ request }) => {
const text = await request.text()
global.sentryEvents.push(
...text.split('\n').map((x) => JSON.parse(x) as Sentry.Event),
Expand All @@ -78,6 +79,7 @@ export async function createBeforeEach() {
}

export async function createAfterEach() {
await flushSentry()
global.server.resetHandlers()
await global.cache.quit()
// redis.quit() creates a thread to close the connection.
Expand Down

0 comments on commit c3f125e

Please sign in to comment.