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