Skip to content

fix: use test mode as not production #1612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtimes/js/encore.dev/internal/runtime/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Runtime } from "./napi/napi.cjs";

export * from "./napi/napi.cjs";

const testMode = process.env.NODE_ENV === "test";
const testMode = process.env.NODE_ENV !== "production";

export const RT = new Runtime({
testMode,
Expand Down
2 changes: 1 addition & 1 deletion runtimes/js/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Runtime {

let test_mode = options
.test_mode
.unwrap_or(std::env::var("NODE_ENV").is_ok_and(|val| val == "test"));
.unwrap_or(std::env::var("NODE_ENV").is_ok_and(|val| val != "production"));
let is_worker = options.is_worker.unwrap_or(false);
let runtime = encore_runtime_core::Runtime::builder()
.with_test_mode(test_mode)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { apiCall, streamIn, streamOut, streamInOut } from "encore.dev/internal/codegen/api";

const TEST_ENDPOINTS = typeof ENCORE_DROP_TESTS === "undefined" && process.env.NODE_ENV === "test"
const TEST_ENDPOINTS = typeof ENCORE_DROP_TESTS === "undefined" && process.env.NODE_ENV !== "production"
? await import("./endpoints_testing.js")
: null;

{{#each endpoints}}
export async function {{name}}(params) {
if (typeof ENCORE_DROP_TESTS === "undefined" && process.env.NODE_ENV === "test") {
if (typeof ENCORE_DROP_TESTS === "undefined" && process.env.NODE_ENV !== "production") {
return TEST_ENDPOINTS.{{name}}(params);
}

Expand Down