-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: start the emulator even if a GA isn't found (#35)
Closes #15
- Loading branch information
1 parent
8e1330f
commit e13afed
Showing
13 changed files
with
958 additions
and
704 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; | ||
"roots": [ | ||
"<rootDir>/src" | ||
], | ||
"testMatch": [ | ||
"**/__tests__/**/*.+(ts)", | ||
"**/?(*.)+(spec|test).+(ts)" | ||
], | ||
"transform": { | ||
"^.+\\.(ts)$": "ts-jest" | ||
}, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { createRuntimeHost } from "./runtimeHost"; | ||
import * as detectRuntime from "./runtimes"; | ||
|
||
let spyDetectRuntime: jest.SpyInstance; | ||
const mockConfig = { | ||
appPort: 8080, | ||
appArtifactLocation: "./", | ||
appLocation: "./", | ||
proxyHost: "0.0.0.0", | ||
proxyPort: 4242, | ||
}; | ||
|
||
describe("runtimeHost", () => { | ||
beforeEach(() => { | ||
process.env.DEBUG = ""; | ||
spyDetectRuntime = jest.spyOn(detectRuntime, "detectRuntime"); | ||
spyDetectRuntime.mockReturnValue(detectRuntime.RuntimeType.unknown); | ||
}); | ||
|
||
describe("createRuntimeHost()", () => { | ||
it("appArtifactLocation should be propagated in resulting command", () => { | ||
const rh = createRuntimeHost({ | ||
...mockConfig, | ||
appArtifactLocation: "./foobar", | ||
}); | ||
|
||
expect(spyDetectRuntime).toHaveBeenCalledWith("./"); | ||
expect(rh.command).toContain("@manekinekko/swa-emulator/node_modules/.bin/http-server"); | ||
expect(rh.args).toEqual(["./foobar", "-p", "8080", "-c-1", "--proxy", "http://0.0.0.0:4242/?"]); | ||
}); | ||
|
||
it("appArtifactLocation should default to ./ if undefined", () => { | ||
const rh = createRuntimeHost({ | ||
...mockConfig, | ||
appArtifactLocation: undefined, | ||
}); | ||
|
||
expect(spyDetectRuntime).toHaveBeenCalledWith("./"); | ||
expect(rh.command).toContain("@manekinekko/swa-emulator/node_modules/.bin/http-server"); | ||
expect(rh.args).toEqual(["./", "-p", "8080", "-c-1", "--proxy", "http://0.0.0.0:4242/?"]); | ||
}); | ||
|
||
it("proxyHost should be propagated in resulting command", () => { | ||
const rh = createRuntimeHost({ | ||
...mockConfig, | ||
proxyHost: "127.0.0.1", | ||
}); | ||
|
||
expect(spyDetectRuntime).toHaveBeenCalledWith("./"); | ||
expect(rh.command).toContain("@manekinekko/swa-emulator/node_modules/.bin/http-server"); | ||
expect(rh.args).toEqual(["./", "-p", "8080", "-c-1", "--proxy", "http://127.0.0.1:4242/?"]); | ||
}); | ||
|
||
it("proxyPort should be propagated in resulting command", () => { | ||
const rh = createRuntimeHost({ | ||
...mockConfig, | ||
proxyPort: 3000, | ||
}); | ||
|
||
expect(spyDetectRuntime).toHaveBeenCalledWith("./"); | ||
expect(rh.command).toContain("@manekinekko/swa-emulator/node_modules/.bin/http-server"); | ||
expect(rh.args).toEqual(["./", "-p", "8080", "-c-1", "--proxy", "http://0.0.0.0:3000/?"]); | ||
}); | ||
|
||
it("appLocation should be propagated to the runtime detector", () => { | ||
const rh = createRuntimeHost({ | ||
...mockConfig, | ||
appLocation: "./foobar", | ||
}); | ||
|
||
expect(spyDetectRuntime).toHaveBeenCalledWith("./foobar"); | ||
expect(rh.command).toContain("@manekinekko/swa-emulator/node_modules/.bin/http-server"); | ||
expect(rh.args).toEqual(["./", "-p", "8080", "-c-1", "--proxy", "http://0.0.0.0:4242/?"]); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.