Skip to content

Commit

Permalink
don't use installGlobals (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinggoesgaming authored Jul 25, 2024
1 parent d1293e9 commit ffc7d04
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
4 changes: 1 addition & 3 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import crypto from 'crypto'
import { createRequestHandler } from '@remix-run/express'
import { type ServerBuild, installGlobals } from '@remix-run/node'
import { type ServerBuild } from '@remix-run/node'
import { ip as ipAddress } from 'address'
import chalk from 'chalk'
import closeWithGrace from 'close-with-grace'
Expand All @@ -11,8 +11,6 @@ import getPort, { portNumbers } from 'get-port'
import helmet from 'helmet'
import morgan from 'morgan'

installGlobals()

const MODE = process.env.NODE_ENV ?? 'development'
const IS_PROD = MODE === 'production'
const IS_DEV = MODE === 'development'
Expand Down
12 changes: 2 additions & 10 deletions tests/setup/custom-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ expect.extend({
}
},
async toHaveSessionForUser(response: Response, userId: string) {
const setCookies = getSetCookie(response.headers)
const setCookies = response.headers.getSetCookie()
const sessionSetCookie = setCookies.find(
(c) => setCookieParser.parseString(c).name === 'en_session',
)
Expand Down Expand Up @@ -115,7 +115,7 @@ expect.extend({
}
},
async toSendToast(response: Response, toast: ToastInput) {
const setCookies = getSetCookie(response.headers)
const setCookies = response.headers.getSetCookie()
const toastSetCookie = setCookies.find(
(c) => setCookieParser.parseString(c).name === 'en_toast',
)
Expand Down Expand Up @@ -164,11 +164,3 @@ declare module 'vitest' {
interface Assertion<T = any> extends CustomMatchers<T> {}
interface AsymmetricMatchersContaining extends CustomMatchers {}
}

function getSetCookie(headers: Headers) {
// this is a sort of polyfill for headers.getSetCookie
// https://github.com/microsoft/TypeScript/issues/55270
// https://github.com/remix-run/remix/issues/7067
// @ts-expect-error see the two issues above
return headers.getAll('set-cookie') as Array<string>
}
3 changes: 0 additions & 3 deletions tests/setup/setup-test-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import './db-setup.ts'
import '#app/utils/env.server.ts'
// we need these to be imported first 👆

import { installGlobals } from '@remix-run/node'
import { cleanup } from '@testing-library/react'
import { afterEach, beforeEach, vi, type MockInstance } from 'vitest'
import { server } from '#tests/mocks/index.ts'
import './custom-matchers.ts'

installGlobals()

afterEach(() => server.resetHandlers())
afterEach(() => cleanup())

Expand Down

0 comments on commit ffc7d04

Please sign in to comment.