Remove IS_TEST env constant

This commit is contained in:
Dan Abramov
2024-12-13 03:52:03 +00:00
parent 2a26e396f8
commit 8fa630ab6c
8 changed files with 10 additions and 12 deletions
+1 -1
View File
@@ -54,4 +54,4 @@ jobs:
run: yarn intl:build
- name: Run tests
run: |
NODE_ENV=test EXPO_PUBLIC_ENV=test yarn test --forceExit
NODE_ENV=test yarn test --forceExit
+1 -1
View File
@@ -20,7 +20,7 @@ build-web-embed: ## Compile web embed bundle, copy to bskyweb/embedr* directorie
.PHONY: test
test: ## Run all tests
NODE_ENV=test EXPO_PUBLIC_ENV=test yarn test
NODE_ENV=test yarn test
.PHONY: lint
lint: ## Run style checks and verify syntax
+1 -2
View File
@@ -5,9 +5,8 @@ import {LogBox} from 'react-native'
import {registerRootComponent} from 'expo'
import App from '#/App'
import {IS_TEST} from '#/env'
if (IS_TEST) {
if (process.env.NODE_ENV === 'test') {
LogBox.ignoreAllLogs() // suppress all logs in tests
} else {
LogBox.ignoreLogs(['Require cycle:']) // suppress require-cycle warnings, it's fine
-1
View File
@@ -1,4 +1,3 @@
export const IS_TEST = process.env.EXPO_PUBLIC_ENV === 'test'
export const IS_DEV = __DEV__
export const IS_PROD = !IS_DEV
export const LOG_DEBUG = process.env.EXPO_PUBLIC_LOG_DEBUG || ''
+1 -1
View File
@@ -18,7 +18,7 @@ logger.error(error[, metadata])
#### Modes
The "modes" referred to here are inferred from the values exported from `#/env`.
Basically, the booleans `IS_DEV`, `IS_TEST`, and `IS_PROD`.
Basically, the booleans `IS_DEV` and `IS_PROD`.
#### Log Levels
-1
View File
@@ -5,7 +5,6 @@ import {nanoid} from 'nanoid/non-secure'
import {Logger, LogLevel, sentryTransport} from '#/logger'
jest.mock('#/env', () => ({
IS_TEST: true,
IS_DEV: false,
IS_PROD: false,
/*
+3 -3
View File
@@ -173,7 +173,7 @@ export class Logger {
protected debugContextRegexes: RegExp[] = []
constructor({
enabled = !env.IS_TEST,
enabled = process.env.NODE_ENV !== 'test',
level = env.LOG_LEVEL as LogLevel,
debug = env.LOG_DEBUG || '',
}: {
@@ -266,11 +266,11 @@ export class Logger {
*/
export const logger = new Logger()
if (!env.IS_TEST) {
if (process.env.NODE_ENV !== 'test') {
logger.addTransport(createBitdriftTransport())
}
if (env.IS_DEV && !env.IS_TEST) {
if (env.IS_DEV && process.env.NODE_ENV !== 'test') {
logger.addTransport(consoleTransport)
/*
+3 -2
View File
@@ -25,7 +25,6 @@ import {
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {atoms as a, useTheme} from '#/alf'
import {Text} from '#/components/Typography'
import {IS_TEST} from '#/env'
const TIMEOUT = 2e3
@@ -33,7 +32,9 @@ export function show(
message: string,
icon: FontAwesomeProps['icon'] = 'check',
) {
if (IS_TEST) return
if (process.env.NODE_ENV === 'test') {
return
}
AccessibilityInfo.announceForAccessibility(message)
const item = new RootSiblings(
<Toast message={message} icon={icon} destroy={() => item.destroy()} />,