Skip to content

Commit

Permalink
[ECO-2301] Fix server/env.ts import for test; flatten turbo.json
Browse files Browse the repository at this point in the history
…scripts and set to `loose` mode (#298)
  • Loading branch information
xbtmatt authored Oct 13, 2024
1 parent c7dd163 commit 59d727d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 48 deletions.
20 changes: 12 additions & 8 deletions src/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build": "pnpm i && pnpm load-env -- turbo run build",
"build:debug": "pnpm i && pnpm load-env -- turbo run build:debug",
"clean": "turbo run clean --no-cache --force && rm -rf .turbo && rm -rf sdk/.turbo && rm -rf frontend/.turbo && rm -rf frontend/.next",
"dev": "pnpm load-env -- turbo run dev --no-cache --force --parallel --continue",
"dev": "pnpm load-env -- turbo run dev --force --parallel --continue",
"dev:debug": "pnpm dotenv -v FETCH_DEBUG=true -- pnpm run dev",
"dev:debug-verbose": "pnpm dotenv -v FETCH_DEBUG_VERBOSE=true -- pnpm run dev",
"down": "pnpm run prune",
Expand All @@ -31,16 +31,20 @@
"lint": "turbo run lint",
"lint:fix": "turbo run lint -- --fix",
"load-env": "dotenv -e .env.local -e .env -e .env.example -e ../docker/example.local.env -e ../docker/.env",
"load-test-env": "pnpm run load-env -- dotenv -e ci.env",
"load-env:test": "dotenv -e .env.local -e .env -e .env.example -e ../docker/example.local.env -e ../docker/.env -e ci.env",
"load-env:test-debug": "dotenv -e .env.local -e .env -e .env.example -e ../docker/example.local.env -e ../docker/.env -e ci.env -v FETCH_DEBUG=true",
"load-env:test-verbose": "dotenv -e .env.local -e .env -e .env.example -e ../docker/example.local.env -e ../docker/.env -e ci.env -v FETCH_DEBUG=true VERBOSE_TEST_LOGS=true",
"load-env:unit-test": "dotenv -e .env.local -e .env -e .env.example -e ../docker/example.local.env -e ../docker/.env -e ci.env -v NO_TEST_SETUP=true",
"prune": "../docker/utils/prune.sh --reset-localnet --yes",
"restart": "pnpm run down && pnpm run up",
"start": "dotenv -e .env.local -e .env -- turbo run start",
"test": "pnpm run load-test-env -- turbo run test --no-cache --force",
"test:debug": "pnpm run load-test-env -- dotenv -v FETCH_DEBUG=true -- pnpm run test",
"test:parallel": "pnpm run load-test-env -- turbo run test:parallel --no-cache --force",
"test:sequential": "pnpm run load-test-env -- turbo run test:sequential --no-cache --force",
"test:verbose": "pnpm run load-test-env -- dotenv -v VERBOSE_TEST_LOGS=true -- pnpm run test --force",
"unit-test": "pnpm run load-test-env -- turbo run unit-test",
"test": "pnpm run load-env:test -- turbo run test --force",
"test:debug": "pnpm run load-env:test-debug -- turbo run test --force",
"test:frontend": "pnpm run load-env:test -- turbo run test --filter @econia-labs/emojicoin-frontend --log-prefix none",
"test:parallel": "pnpm run load-env:test -- turbo run test:parallel --force --log-prefix none",
"test:sequential": "pnpm run load-env:test -- turbo run test:sequential --force --log-prefix none",
"test:verbose": "pnpm run load-env:test-verbose -- turbo run test --force",
"unit-test": "pnpm run load-env:unit-test -- turbo run unit-test --force --log-prefix none --log-order grouped",
"up": "docker compose -f ../docker/compose.local.yaml up -d"
},
"version": "0.0.0",
Expand Down
9 changes: 1 addition & 8 deletions src/typescript/sdk/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ module.exports = {
workerThreads: true,
testEnvironment: "node",
testEnvironmentOptions: {
// If we don't add this, all the jest tests that run/import server-only code will fail to
// import it and thus fail.
customExportConditions: ["react-server", "node", "node-addons"],
},
coveragePathIgnorePatterns: [
"src/cli/local-node.ts",
"src/helpers/misc.ts",
"src/helpers/aptos-client.ts",
"src/utils/env.ts",
],
coveragePathIgnorePatterns: [],
testPathIgnorePatterns: ["dist/*"],
collectCoverage: false,
coverageThreshold: {
Expand Down
14 changes: 6 additions & 8 deletions src/typescript/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,20 @@
"_format": "prettier 'src/**/*.ts' 'tests/**/*.ts' '.eslintrc.js'",
"build": "tsc",
"build:debug": "BUILD_DEBUG=true pnpm run build",
"check": "dotenv -e ../.env.example -e ../.env.local -e ../../docker/example.local.env -e ../../docker/.env -- tsc --noEmit",
"check": "tsc --noEmit",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"e2e:testnet": "pnpm load-test-env -v NO_TEST_SETUP=true -- pnpm jest tests/e2e/queries/testnet --conditions=react-server",
"e2e:testnet": "pnpm load-test-env -v NO_TEST_SETUP=true -- pnpm jest tests/e2e/queries/testnet",
"format": "pnpm _format --write",
"format:check": "pnpm _format --check",
"lint": "eslint 'src/**/*.ts' 'tests/**/*.ts' -c .eslintrc.js",
"lint:fix": "pnpm lint --fix",
"load-env": "dotenv -e ../.env.local -e ../.env -e ../.env.example -e ../../docker/example.local.env -e ../../docker/.env",
"load-test-env": "pnpm run load-env -- dotenv -e ../ci.env",
"pre-commit": "pnpm run pre-commit:install && pnpm run pre-commit:run",
"pre-commit:install": "pre-commit install -c ../../../cfg/pre-commit-config.yaml",
"pre-commit:run": "pre-commit run --all-files -c ../../../cfg/pre-commit-config.yaml",
"test": "pnpm load-test-env -- pnpm run test:parallel && pnpm run test:sequential",
"test:parallel": "pnpm load-test-env -- pnpm jest --conditions=react-server --testPathIgnorePatterns=tests/e2e/broker",
"test:sequential": "pnpm load-test-env -- pnpm jest --conditions=react-server --runInBand tests/e2e/broker",
"unit-test": "pnpm load-test-env -v NO_TEST_SETUP=true -- pnpm jest tests/unit"
"test": "pnpm run test:parallel && pnpm run test:sequential",
"test:parallel": "pnpm jest --testPathIgnorePatterns=tests/e2e/broker",
"test:sequential": "pnpm jest --runInBand tests/e2e/broker",
"unit-test": "pnpm jest tests/unit"
},
"typings": "dist/src/index.d.ts",
"version": "0.0.1"
Expand Down
4 changes: 3 additions & 1 deletion src/typescript/sdk/src/server/env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "server-only";
if (process.env.NODE_ENV !== "test") {
require("server-only");
}

if (typeof process.env.EMOJICOIN_INDEXER_URL === "undefined") {
throw new Error("The indexer processor url must be defined.");
Expand Down
2 changes: 1 addition & 1 deletion src/typescript/sdk/tests/pre-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default async function preTest() {
// @ts-expect-error Using `globalThis` as any for a polyfill for `WebSocket` in node.js.
globalThis.WebSocket = WebSocket;

const startDockerServices = process.env.APTOS_NETWORK === "local";
const startDockerServices = process.env.NEXT_PUBLIC_APTOS_NETWORK === "local";
const setupTest = !process.env.NO_TEST_SETUP;
if (setupTest && startDockerServices) {
// Print an empty line to separate `Determining test suites to run...` from the logs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
execPromise,
spawnWrapper,
} from "./utils";
import { EMOJICOIN_INDEXER_URL } from "../../../src/server-env";
import { EMOJICOIN_INDEXER_URL } from "../../../src/server/env";
import { TableName } from "../../../src/indexer-v2/types/json-types";

const LOCAL_COMPOSE_PATH = path.join(getGitRoot(), "src/docker", "compose.local.yaml");
Expand Down
32 changes: 11 additions & 21 deletions src/typescript/turbo.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
{
"$schema": "https://turbo.build/schema.json",
"globalEnv": [
"EMOJICOIN_INDEXER_URL",
"EMOJICOIN_INDEXER_API_KEY",
"REVALIDATION_TIME",
"ALLOWLISTER3K_URL",
"NEXT_PUBLIC_IS_ALLOWLIST_ENABLED",
"GALXE_CAMPAIGN_ID",
"NEXT_PUBLIC_GALXE_CAMPAIGN_REDIRECT",
"HASH_SEED",
"NEXT_PUBLIC_INTEGRATOR_FEE_RATE_BPS",
"NEXT_PUBLIC_INTEGRATOR_ADDRESS",
"NEXT_PUBLIC_MODULE_ADDRESS",
"NEXT_PUBLIC_REWARDS_MODULE_ADDRESS",
"NEXT_PUBLIC_APTOS_NETWORK",
"NEXT_PUBLIC_BROKER_URL",
"BROKER_PORT",
"FETCH_DEBUG",
"FETCH_DEBUG_VERBOSE",
"VERBOSE_TEST_LOGS"
"envMode": "loose",
"globalDependencies": [
"**/*.env.*",
"**/*.env",
"**/tsconfig.json",
"**/package.json"
],
"globalEnv": [],
"tasks": {
"build": {
"dependsOn": [
Expand All @@ -40,7 +28,8 @@
"outputs": []
},
"dev": {
"cache": false
"cache": false,
"persistent": true
},
"e2e:testnet": {
"outputs": []
Expand All @@ -61,7 +50,8 @@
"dependsOn": [
"build"
],
"outputs": []
"outputs": [],
"persistent": true
},
"test": {
"outputs": []
Expand Down

0 comments on commit 59d727d

Please sign in to comment.