Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/node/src/integrations/spotlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class Spotlight implements Integration {
* Sets up forwarding envelopes to the Spotlight Sidecar
*/
public setup(client: Client): void {
if (process.env.NODE_ENV !== 'development') {
logger.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spoltight enabled?");
if (typeof process === 'object' && process.env && process.env.NODE_ENV !== 'development') {
logger.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?");
}
connectToSpotlight(client, this._options);
}
Expand Down
36 changes: 34 additions & 2 deletions packages/node/test/integrations/spotlight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('Spotlight', () => {
integration.setup(client);

expect(loggerSpy).toHaveBeenCalledWith(
expect.stringContaining("It seems you're not in dev mode. Do you really want to have Spoltight enabled?"),
expect.stringContaining("It seems you're not in dev mode. Do you really want to have Spotlight enabled?"),
);

process.env.NODE_ENV = oldEnvValue;
Expand All @@ -152,9 +152,41 @@ describe('Spotlight', () => {
integration.setup(client);

expect(loggerSpy).not.toHaveBeenCalledWith(
expect.stringContaining("It seems you're not in dev mode. Do you really want to have Spoltight enabled?"),
expect.stringContaining("It seems you're not in dev mode. Do you really want to have Spotlight enabled?"),
);

process.env.NODE_ENV = oldEnvValue;
});

it('handles `process` not being available', () => {
const originalProcess = process;

// @ts-expect-error - TS complains but we explicitly wanna test this
delete global.process;

const integration = new Spotlight({ sidecarUrl: 'http://localhost:8969' });
integration.setup(client);

expect(loggerSpy).not.toHaveBeenCalledWith(
expect.stringContaining("It seems you're not in dev mode. Do you really want to have Spotlight enabled?"),
);

global.process = originalProcess;
});

it('handles `process.env` not being available', () => {
const originalEnv = process.env;

// @ts-expect-error - TS complains but we explicitly wanna test this
delete process.env;

const integration = new Spotlight({ sidecarUrl: 'http://localhost:8969' });
integration.setup(client);

expect(loggerSpy).not.toHaveBeenCalledWith(
expect.stringContaining("It seems you're not in dev mode. Do you really want to have Spotlight enabled?"),
);

process.env = originalEnv;
});
});