-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for automatic APP_ROOT environment variable.
- Loading branch information
Showing
6 changed files
with
46 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
process.env.BUILD_TARGET = "client" | ||
|
||
const snapshotOpts = { | ||
APP_ROOT: expect.any(String) | ||
} | ||
|
||
/* eslint-disable import/no-commonjs */ | ||
// We can't use ESM when relying on the fact the the env from the top is correctly respected. | ||
const api = require(".") | ||
|
||
test("Also serializes BUILD_TARGET", () => { | ||
test("Serializes BUILD_TARGET", () => { | ||
const { raw, stringified, webpack } = api.getEnvironment() | ||
expect(raw).toMatchSnapshot() | ||
expect(stringified).toMatchSnapshot() | ||
expect(webpack).toMatchSnapshot() | ||
expect(raw).toMatchSnapshot(snapshotOpts) | ||
expect(stringified).toMatchSnapshot(snapshotOpts) | ||
expect(webpack).toBeDefined() | ||
}) | ||
|
||
test("Exports BUILD_TARGET", () => { | ||
const { raw } = api.getEnvironment() | ||
expect(raw.BUILD_TARGET).toBe("client") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import { getEnvironment } from "." | ||
|
||
const snapshotOpts = { | ||
APP_ROOT: expect.any(String) | ||
} | ||
|
||
test("Sets up process.env", () => { | ||
expect(process.env.APP_TEST_PATH).toBe("one/two/three.js") | ||
expect(process.env.TEST_IGNORE).toBe("123") | ||
}) | ||
|
||
test("Ignores non app-specific settings", () => { | ||
const { raw, stringified, webpack } = getEnvironment() | ||
expect(raw).toMatchSnapshot() | ||
expect(stringified).toMatchSnapshot() | ||
expect(webpack).toMatchSnapshot() | ||
expect(raw).toMatchSnapshot(snapshotOpts) | ||
expect(stringified).toMatchSnapshot(snapshotOpts) | ||
expect(webpack).toBeDefined() | ||
}) | ||
|
||
test("Supports manually defined envs", () => { | ||
process.env.APP_DATA = "yellow" | ||
const { raw, stringified, webpack } = getEnvironment() | ||
expect(raw).toMatchSnapshot() | ||
expect(stringified).toMatchSnapshot() | ||
expect(webpack).toMatchSnapshot() | ||
expect(raw).toMatchSnapshot(snapshotOpts) | ||
expect(stringified).toMatchSnapshot(snapshotOpts) | ||
expect(webpack).toBeDefined() | ||
delete process.env.APP_DATA | ||
}) | ||
|
||
test("Exports NODE_ENV", () => { | ||
const { raw } = getEnvironment() | ||
expect(raw.NODE_ENV).toBe("test") | ||
}) | ||
|
||
test("Exports APP_ROOT", () => { | ||
const { raw } = getEnvironment() | ||
expect(raw.APP_ROOT).toMatch(/universal-dotenv$/) | ||
}) |